LibreOffice
LibreOffice 6.2 SDK C/C++ API Reference
file.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_OSL_FILE_HXX
21 #define INCLUDED_OSL_FILE_HXX
22 
23 #include "sal/config.h"
24 
25 #include <string.h>
26 
27 #include <cstddef>
28 
29 #include "sal/log.hxx"
30 #include "osl/time.h"
31 #include "rtl/ustring.hxx"
32 
33 #include "osl/file.h"
34 #include "osl/diagnose.h"
35 
36 namespace rtl { class ByteSequence; }
37 
38 namespace osl
39 {
40 
41 
49 class FileBase
50 {
51 public:
52 
53  enum RC {
54  E_None = osl_File_E_None,
55  E_PERM = osl_File_E_PERM,
56  E_NOENT = osl_File_E_NOENT,
57  E_SRCH = osl_File_E_SRCH,
58  E_INTR = osl_File_E_INTR,
59  E_IO = osl_File_E_IO,
60  E_NXIO = osl_File_E_NXIO,
61  E_2BIG = osl_File_E_2BIG,
62  E_NOEXEC = osl_File_E_NOEXEC,
63  E_BADF = osl_File_E_BADF,
64  E_CHILD = osl_File_E_CHILD,
65  E_AGAIN = osl_File_E_AGAIN,
66  E_NOMEM = osl_File_E_NOMEM,
67  E_ACCES = osl_File_E_ACCES,
68  E_FAULT = osl_File_E_FAULT,
69  E_BUSY = osl_File_E_BUSY,
70  E_EXIST = osl_File_E_EXIST,
71  E_XDEV = osl_File_E_XDEV,
72  E_NODEV = osl_File_E_NODEV,
73  E_NOTDIR = osl_File_E_NOTDIR,
74  E_ISDIR = osl_File_E_ISDIR,
75  E_INVAL = osl_File_E_INVAL,
76  E_NFILE = osl_File_E_NFILE,
77  E_MFILE = osl_File_E_MFILE,
78  E_NOTTY = osl_File_E_NOTTY,
79  E_FBIG = osl_File_E_FBIG,
80  E_NOSPC = osl_File_E_NOSPC,
81  E_SPIPE = osl_File_E_SPIPE,
82  E_ROFS = osl_File_E_ROFS,
83  E_MLINK = osl_File_E_MLINK,
84  E_PIPE = osl_File_E_PIPE,
85  E_DOM = osl_File_E_DOM,
86  E_RANGE = osl_File_E_RANGE,
87  E_DEADLK = osl_File_E_DEADLK,
88  E_NAMETOOLONG = osl_File_E_NAMETOOLONG,
89  E_NOLCK = osl_File_E_NOLCK,
90  E_NOSYS = osl_File_E_NOSYS,
91  E_NOTEMPTY = osl_File_E_NOTEMPTY,
92  E_LOOP = osl_File_E_LOOP,
93  E_ILSEQ = osl_File_E_ILSEQ,
94  E_NOLINK = osl_File_E_NOLINK,
95  E_MULTIHOP = osl_File_E_MULTIHOP,
96  E_USERS = osl_File_E_USERS,
97  E_OVERFLOW = osl_File_E_OVERFLOW,
98  E_NOTREADY = osl_File_E_NOTREADY,
99  E_invalidError = osl_File_E_invalidError,
100  E_TIMEDOUT = osl_File_E_TIMEDOUT,
101  E_NETWORK = osl_File_E_NETWORK
102  };
103 
104 
105 public:
106 
127  static RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
128  {
129  return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
130  }
131 
166  static RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
167  {
168  return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
169  }
170 
185  static RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
186  {
187  return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
188  }
189 
204  static RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
205  {
206  return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
207  }
208 
236  static RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
237  {
238  return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
239  }
240 
250  static RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
251  {
252  return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
253  }
254 
303  ::rtl::OUString* pustrDirectoryURL,
304  oslFileHandle* pHandle,
305  ::rtl::OUString* pustrTempFileURL)
306  {
307  rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : NULL;
308  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : NULL;
309 
310  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
311  }
312 };
313 
314 
320 class VolumeDevice : public FileBase
321 {
322  oslVolumeDeviceHandle _aHandle;
323 
324 public:
325 
329  VolumeDevice() : _aHandle( NULL )
330  {
331  }
332 
339  VolumeDevice( const VolumeDevice & rDevice )
340  {
341  _aHandle = rDevice._aHandle;
342  if ( _aHandle )
343  osl_acquireVolumeDeviceHandle( _aHandle );
344  }
345 
350  {
351  if ( _aHandle )
352  osl_releaseVolumeDeviceHandle( _aHandle );
353  }
354 
361  VolumeDevice & operator =( const VolumeDevice & rDevice )
362  {
363  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
364 
365  if ( newHandle )
366  osl_acquireVolumeDeviceHandle( newHandle );
367 
368  if ( _aHandle )
369  osl_releaseVolumeDeviceHandle( _aHandle );
370 
371  _aHandle = newHandle;
372 
373  return *this;
374  }
375 
382  {
383  rtl::OUString aPath;
384  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
385  return aPath;
386  }
387 
388  friend class VolumeInfo;
389 };
390 
391 
392 class Directory;
393 
403 {
404  oslVolumeInfo _aInfo;
405  sal_uInt32 _nMask;
406  VolumeDevice _aDevice;
407 
412 
416  VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
417 
418 public:
419 
425  VolumeInfo( sal_uInt32 nMask )
426  : _nMask( nMask )
427  {
428  memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
429  _aInfo.uStructSize = sizeof( oslVolumeInfo );
430  _aInfo.pDeviceHandle = &_aDevice._aHandle;
431  }
432 
434  {
435  if( _aInfo.ustrFileSystemName )
437  }
438 
446  bool isValid( sal_uInt32 nMask ) const
447  {
448  return ( nMask & _aInfo.uValidFields ) == nMask;
449  }
450 
456  bool getRemoteFlag() const
457  {
458  return (_aInfo.uAttributes & osl_Volume_Attribute_Remote) != 0;
459  }
460 
466  bool getRemoveableFlag() const
467  {
468  return (_aInfo.uAttributes & osl_Volume_Attribute_Removeable) != 0;
469  }
470 
477  bool getCompactDiscFlag() const
478  {
479  return (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc) != 0;
480  }
481 
488  bool getFloppyDiskFlag() const
489  {
490  return (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk) != 0;
491  }
492 
499  bool getFixedDiskFlag() const
500  {
501  return (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk) != 0;
502  }
503 
510  bool getRAMDiskFlag() const
511  {
512  return (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk) != 0;
513  }
514 
522  sal_uInt64 getTotalSpace() const
523  {
524  return _aInfo.uTotalSpace;
525  }
526 
534  sal_uInt64 getFreeSpace() const
535  {
536  return _aInfo.uFreeSpace;
537  }
538 
546  sal_uInt64 getUsedSpace() const
547  {
548  return _aInfo.uUsedSpace;
549  }
550 
558  sal_uInt32 getMaxNameLength() const
559  {
560  return _aInfo.uMaxNameLength;
561  }
562 
570  sal_uInt32 getMaxPathLength() const
571  {
572  return _aInfo.uMaxPathLength;
573  }
574 
583  {
585  }
586 
587 
596  {
597  return _aDevice;
598  }
599 
607  {
608  return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
609  }
610 
619  {
621  }
622 
623  friend class Directory;
624 };
625 
626 
627 class DirectoryItem;
628 
635 {
636  oslFileStatus _aStatus;
637  sal_uInt32 _nMask;
638 
643 
647  FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
648 
649 public:
650 
651  enum Type {
660  };
661 
667  FileStatus(sal_uInt32 nMask)
668  : _nMask(nMask)
669  {
670  memset(&_aStatus, 0, sizeof(_aStatus));
671  _aStatus.uStructSize = sizeof(_aStatus);
672  }
673 
677  {
678  if ( _aStatus.ustrFileURL )
679  rtl_uString_release( _aStatus.ustrFileURL );
680  if ( _aStatus.ustrLinkTargetURL )
682  if ( _aStatus.ustrFileName )
683  rtl_uString_release( _aStatus.ustrFileName );
684  }
685 
695  bool isValid( sal_uInt32 nMask ) const
696  {
697  return ( nMask & _aStatus.uValidFields ) == nMask;
698  }
699 
706  {
707  SAL_INFO_IF(
708  !isValid(osl_FileStatus_Mask_Type), "sal.osl",
709  "no FileStatus Type determined");
710  return isValid(osl_FileStatus_Mask_Type)
711  ? static_cast< Type >(_aStatus.eType) : Unknown;
712  }
713 
723  bool isDirectory() const
724  {
725  return ( getFileType() == Directory || getFileType() == Volume );
726  }
727 
738  bool isRegular() const
739  {
740  return ( getFileType() == Regular );
741  }
742 
751  bool isLink() const
752  {
753  return ( getFileType() == Link );
754  }
755 
762  sal_uInt64 getAttributes() const
763  {
764  SAL_INFO_IF(
765  !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
766  "no FileStatus Attributes determined");
767  return _aStatus.uAttributes;
768  }
769 
778  {
779  SAL_INFO_IF(
780  !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
781  "no FileStatus CreationTime determined");
782  return _aStatus.aCreationTime;
783  }
784 
793  {
794  SAL_INFO_IF(
795  !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
796  "no FileStatus AccessTime determined");
797  return _aStatus.aAccessTime;
798  }
799 
808  {
809  SAL_INFO_IF(
810  !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
811  "no FileStatus ModifyTime determined");
812  return _aStatus.aModifyTime;
813  }
814 
821  sal_uInt64 getFileSize() const
822  {
823  SAL_INFO_IF(
824  !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
825  "no FileStatus FileSize determined");
826  return _aStatus.uFileSize;
827  }
828 
836  {
837  SAL_INFO_IF(
838  !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
839  "no FileStatus FileName determined");
840  return isValid(osl_FileStatus_Mask_FileName)
841  ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
842  }
843 
844 
853  {
854  SAL_INFO_IF(
855  !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
856  "no FileStatus FileURL determined");
857  return isValid(osl_FileStatus_Mask_FileURL)
858  ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
859  }
860 
869  {
870  SAL_INFO_IF(
871  !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
872  "no FileStatus LinkTargetURL determined");
873  return isValid(osl_FileStatus_Mask_LinkTargetURL)
875  }
876 
877  friend class DirectoryItem;
878 };
879 
880 
887 class File: public FileBase
888 {
889  oslFileHandle _pData;
890  ::rtl::OUString _aPath;
891 
896 
900  File& operator = ( File& ) SAL_DELETED_FUNCTION;
901 
902 public:
903 
910  File( const ::rtl::OUString& ustrFileURL ): _pData( NULL ), _aPath( ustrFileURL ) {}
911 
916  {
917  close();
918  }
919 
927  rtl::OUString getURL() const { return _aPath; }
928 
971  RC open( sal_uInt32 uFlags )
972  {
973  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
974  }
975 
990  {
992 
993  if( _pData )
994  {
995  Error=osl_closeFile( _pData );
996  _pData = NULL;
997  }
998 
999  return static_cast< RC >( Error );
1000  }
1001 
1018  SAL_WARN_UNUSED_RESULT RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
1019  {
1020  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1021  }
1022 
1038  RC getPos( sal_uInt64& uPos )
1039  {
1040  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1041  }
1042 
1065  {
1066  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1067  }
1068 
1086  RC setSize( sal_uInt64 uSize )
1087  {
1088  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1089  }
1090 
1110  RC getSize( sal_uInt64 &rSize )
1111  {
1112  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1113  }
1114 
1146  RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1147  {
1148  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1149  }
1150 
1184  RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1185  {
1186  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1187  }
1188 
1189 
1214  {
1215  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1216  }
1217 
1237  RC sync() const
1238  {
1239  OSL_PRECOND(_pData, "File::sync(): File not open");
1240  return static_cast< RC >(osl_syncFile(_pData));
1241  }
1242 
1268  static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1269  {
1270  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1271  }
1272 
1296  static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1297  {
1298  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1299  }
1300 
1328  static RC remove( const ::rtl::OUString& ustrFileURL )
1329  {
1330  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1331  }
1332 
1348  static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1349  {
1350  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1351  }
1352 
1374  static RC setTime(
1375  const ::rtl::OUString& ustrFileURL,
1376  const TimeValue& rCreationTime,
1377  const TimeValue& rLastAccessTime,
1378  const TimeValue& rLastWriteTime )
1379  {
1380  return static_cast< RC >( osl_setFileTime(
1381  ustrFileURL.pData,
1382  &rCreationTime,
1383  &rLastAccessTime,
1384  &rLastWriteTime ) );
1385  }
1386 
1387  friend class DirectoryItem;
1388 };
1389 
1390 
1397 {
1398  oslDirectoryItem _pData;
1399 
1400 public:
1401 
1405  DirectoryItem(): _pData( NULL )
1406  {
1407  }
1408 
1412  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1413  {
1414  if( _pData )
1415  osl_acquireDirectoryItem( _pData );
1416  }
1417 
1422  {
1423  if( _pData )
1424  osl_releaseDirectoryItem( _pData );
1425  }
1426 
1431  {
1432  if (&rItem != this)
1433  {
1434  if( _pData )
1435  osl_releaseDirectoryItem( _pData );
1436 
1437  _pData = rItem._pData;
1438 
1439  if( _pData )
1440  osl_acquireDirectoryItem( _pData );
1441  }
1442  return *this;
1443  }
1444 
1451  bool is()
1452  {
1453  return _pData != NULL;
1454  }
1455 
1489  static RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1490  {
1491  if( rItem._pData)
1492  {
1493  osl_releaseDirectoryItem( rItem._pData );
1494  rItem._pData = NULL;
1495  }
1496 
1497  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1498  }
1499 
1532  {
1533  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1534  }
1535 
1551  bool isIdenticalTo( const DirectoryItem &pOther )
1552  {
1553  return osl_identicalDirectoryItem( _pData, pOther._pData );
1554  }
1555 
1556  friend class Directory;
1557 };
1558 
1559 
1571 {
1572 public:
1574 
1584  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1585 };
1586 
1587 
1588 // This just an internal helper function for
1589 // private use.
1590 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1591 {
1592  static_cast<DirectoryCreationObserver*>(pData)->DirectoryCreated(aDirectoryUrl);
1593 }
1594 
1601 class Directory: public FileBase
1602 {
1603  oslDirectory _pData;
1604  ::rtl::OUString _aPath;
1605 
1610 
1614  Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1615 
1616 public:
1617 
1625  Directory( const ::rtl::OUString& strPath ): _pData( NULL ), _aPath( strPath )
1626  {
1627  }
1628 
1633  {
1634  close();
1635  }
1636 
1644  rtl::OUString getURL() const { return _aPath; }
1645 
1664  {
1665  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1666  }
1667 
1678  bool isOpen() { return _pData != NULL; }
1679 
1692  {
1693  oslFileError Error = osl_File_E_BADF;
1694 
1695  if( _pData )
1696  {
1697  Error=osl_closeDirectory( _pData );
1698  _pData = NULL;
1699  }
1700 
1701  return static_cast< RC >( Error );
1702  }
1703 
1704 
1722  {
1723  close();
1724  return open();
1725  }
1726 
1749  RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1750  {
1751  if( rItem._pData )
1752  {
1753  osl_releaseDirectoryItem( rItem._pData );
1754  rItem._pData = NULL;
1755  }
1756  return static_cast<RC>(osl_getNextDirectoryItem( _pData, &rItem._pData, nHint ));
1757  }
1758 
1759 
1790  static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1791  {
1792  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1793  }
1794 
1825  static RC create(
1826  const ::rtl::OUString& ustrDirectoryURL,
1827  sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1828  {
1829  return static_cast< RC >(
1830  osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1831  }
1832 
1860  static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1861  {
1862  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1863  }
1864 
1901  static RC createPath(
1902  const ::rtl::OUString& aDirectoryUrl,
1903  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1904  {
1905  return static_cast< RC >(osl_createDirectoryPath(
1906  aDirectoryUrl.pData,
1907  aDirectoryCreationObserver ? onDirectoryCreated : NULL,
1908  aDirectoryCreationObserver));
1909  }
1910 };
1911 
1912 } /* namespace osl */
1913 
1914 #endif // INCLUDED_OSL_FILE_HXX
1915 
1916 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 uFreeSpace
Free space on the volume for the current process/user.
Definition: file.h:573
Definition: file.h:123
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1749
Definition: file.h:111
SAL_DLLPUBLIC oslFileError osl_removeDirectory(rtl_uString *pustrDirectoryURL)
Remove an empty directory.
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:565
Definition: file.h:103
#define SAL_INFO_IF(condition, area, stream)
Produce log entry from stream in the given log area if condition is true.
Definition: log.hxx:313
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:381
#define osl_Volume_Attribute_Removeable
Definition: file.h:524
bool isRegular() const
Is it a regular file?
Definition: file.hxx:738
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
Definition: file.h:132
sal_uInt32 uMaxPathLength
Maximum length of a full qualified path in system notation.
Definition: file.h:577
#define osl_File_OpenFlag_Read
Definition: file.h:630
sal_uInt32 uMaxNameLength
Maximum length of file name of a single item.
Definition: file.h:575
Definition: file.h:325
Definition: file.h:131
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1590
Definition: file.h:93
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:927
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:563
Definition: file.h:330
Base class for all File System specific objects.
Definition: file.hxx:49
SAL_DLLPUBLIC oslFileError osl_setFileTime(rtl_uString *pustrFileURL, const TimeValue *aCreationTime, const TimeValue *aLastAccessTime, const TimeValue *aLastWriteTime)
Set the file time.
RC open(sal_uInt32 uFlags)
Open a regular file.
Definition: file.hxx:971
Type
Definition: file.hxx:651
static RC getSystemPathFromFileURL(const ::rtl::OUString &ustrFileURL,::rtl::OUString &ustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:185
static RC move(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Move a file or directory to a new destination or renames it.
Definition: file.hxx:1296
Definition: file.h:331
Definition: file.h:120
SAL_DLLPUBLIC oslFileError osl_getFileURLFromSystemPath(rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.h:108
Definition: file.h:119
static RC createTempFile(::rtl::OUString *pustrDirectoryURL, oslFileHandle *pHandle,::rtl::OUString *pustrTempFileURL)
Creates a temporary file in the directory provided by the caller or the directory returned by getTemp...
Definition: file.hxx:302
SAL_DLLPUBLIC oslFileError osl_readLine(oslFileHandle Handle, sal_Sequence **ppSequence)
Read a line from a file.
static RC setTime(const ::rtl::OUString &ustrFileURL, const TimeValue &rCreationTime, const TimeValue &rLastAccessTime, const TimeValue &rLastWriteTime)
Set the file time.
Definition: file.hxx:1374
Definition: file.h:87
Definition: file.h:96
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:380
sal_uInt64 uFileSize
Size in bytes of the file.
Definition: file.h:396
#define OSL_PRECOND(c, m)
Check the precondition of functions.
Definition: diagnose.h:109
SAL_DLLPUBLIC oslFileError osl_releaseVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Release a volume device handle.
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:807
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:531
~Directory()
Destructor.
Definition: file.hxx:1632
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:695
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1663
The directory item class object provides access to file status information.
Definition: file.hxx:1396
Definition: file.h:109
bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:499
SAL_DLLPUBLIC oslFileError osl_getVolumeDeviceMountPath(oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL)
Get the full qualified URL where a device is mounted to.
SAL_DLLPUBLIC oslFileError osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize)
Get the file size of an open file.
static RC getAbsoluteFileURL(const ::rtl::OUString &ustrBaseDirectoryURL, const ::rtl::OUString &ustrRelativeFileURL,::rtl::OUString &ustrAbsoluteFileURL)
Convert a path relative to a given directory into an full qualified file URL.
Definition: file.hxx:166
void * oslDirectory
Definition: file.h:139
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:534
SAL_DLLPUBLIC oslFileError osl_createDirectoryWithFlags(rtl_uString *url, sal_uInt32 flags)
Create a directory, passing flags.
RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
Write a number of bytes to a file.
Definition: file.hxx:1184
struct _oslVolumeInfo oslVolumeInfo
Structure containing information about volumes.
bool isLink() const
Is it a link?
Definition: file.hxx:751
Definition: file.h:328
#define osl_FileStatus_Mask_ModifyTime
Definition: file.h:364
Definition: file.h:97
Definition: file.h:327
static RC getTempDirURL(::rtl::OUString &ustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
Definition: file.hxx:250
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:425
rtl_uString * ustrFileSystemName
Points to a string that receives the name of the file system type.
Definition: file.h:581
::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:852
Definition: file.h:118
bool getRemoteFlag() const
Check the remote flag.
Definition: file.hxx:456
#define osl_Volume_Attribute_CompactDisc
Definition: file.h:526
Definition: file.h:110
bool getFloppyDiskFlag() const
Check the floppy disc flag.
Definition: file.hxx:488
Definition: file.h:126
Definition: file.h:86
FileStatus(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:667
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:339
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1531
Definition: file.h:115
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:762
SAL_DLLPUBLIC oslFileError osl_getVolumeInformation(rtl_uString *pustrDirectoryURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask)
Retrieve information about a volume.
bool is()
Check for validity of this instance.
Definition: file.hxx:1451
SAL_DLLPUBLIC oslFileError osl_writeFile(oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten)
Write a number of bytes to a file.
sal_uInt32 uAttributes
Attributes of the volume (remote and/or removable)
Definition: file.h:567
RC close()
Close an open file.
Definition: file.hxx:989
oslVolumeDeviceHandle * pDeviceHandle
Pointer to handle the receives underlying device.
Definition: file.h:584
Main goals and usage hints.
::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:835
SAL_DLLPUBLIC oslFileError osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
Retrieve the next item of a previously opened directory.
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:1644
Definition: file.h:99
Definition: file.h:121
SAL_WARN_UNUSED_RESULT SAL_DLLPUBLIC oslFileError osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos)
Set the internal position pointer of an open file.
#define osl_Volume_Attribute_FloppyDisk
Definition: file.h:529
#define osl_Volume_Attribute_FixedDisk
Definition: file.h:527
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1038
unsigned char sal_Bool
Definition: types.h:38
static RC create(const ::rtl::OUString &ustrDirectoryURL, sal_uInt32 flags=osl_File_OpenFlag_Read|osl_File_OpenFlag_Write)
Create a directory.
Definition: file.hxx:1825
#define osl_FileStatus_Mask_CreationTime
Definition: file.h:362
VolumeDevice()
Constructor.
Definition: file.hxx:329
Base class for observers of directory creation notifications.
Definition: file.hxx:1570
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1625
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:777
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:910
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1430
Provides simple diagnostic support.
rtl_uString * ustrFileURL
Full URL of the file.
Definition: file.h:402
SAL_DLLPUBLIC oslFileError osl_getTempDirURL(rtl_uString **pustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
The VolumeInfo class.
Definition: file.hxx:402
Definition: file.h:107
The file class object provides access to file contents and attributes.
Definition: file.hxx:887
#define osl_FileStatus_Mask_FileURL
Definition: file.h:367
bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1551
Definition: file.h:95
TimeValue aAccessTime
Last access time in nanoseconds since 1/1/1970.
Definition: file.h:392
#define osl_FileStatus_Mask_Attributes
Definition: file.h:361
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:570
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:368
SAL_DLLPUBLIC oslFileError osl_getFileStatus(oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
Retrieve information about a single file or directory.
SAL_DLLPUBLIC oslFileError osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos)
Retrieve the current position of the internal pointer of an open file.
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:595
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:792
RC
Definition: file.hxx:53
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:558
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:302
Definition: file.h:88
SAL_DLLPUBLIC oslFileError osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.h:89
SAL_DLLPUBLIC oslFileError osl_openDirectory(rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory)
Open a directory for enumerating its contents.
Definition: file.h:124
Definition: file.h:122
bool getCompactDiscFlag() const
Check the compact disc flag.
Definition: file.hxx:477
DirectoryItem()
Constructor.
Definition: file.hxx:1405
bool isCasePreservingFileSystem() const
Return whether the file system preserves the case of file and directory names or not.
Definition: file.hxx:618
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:446
void * oslDirectoryItem
Definition: file.h:140
SAL_DLLPUBLIC oslFileError osl_searchFileURL(rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL)
Search a full qualified system path or a file URL.
SAL_DLLPUBLIC oslFileError osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
Test if the end of a file is reached.
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:382
SAL_DLLPUBLIC oslFileError osl_openFile(rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags)
Open a regular file.
void * oslVolumeDeviceHandle
Definition: file.h:450
rtl_uString * ustrLinkTargetURL
Full URL of the target file if the file itself is a link.
Definition: file.h:406
bool isOpen()
Query if directory is open.
Definition: file.hxx:1678
#define osl_File_OpenFlag_Write
Definition: file.h:631
Definition: file.h:125
RC reset()
Resets the directory item enumeration to the beginning.
Definition: file.hxx:1721
Definition: file.h:112
Definition: file.h:102
Definition: file.h:130
sal_uInt64 uAttributes
File attributes.
Definition: file.h:386
bool isDirectory() const
Is it a directory? This method returns True for both directories, and volumes.
Definition: file.hxx:723
SAL_DLLPUBLIC oslFileError osl_setFileAttributes(rtl_uString *pustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
static RC searchFileURL(const ::rtl::OUString &ustrFileName, const ::rtl::OUString &ustrSearchPath,::rtl::OUString &ustrFileURL)
Searche a full qualified system path or a file URL.
Definition: file.hxx:236
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1146
#define osl_Volume_Attribute_Case_Sensitive
Definition: file.h:532
sal_uInt64 uUsedSpace
Used space on the volume for the current process/user.
Definition: file.h:571
oslFileType eType
The type of the file (file, directory, volume).
Definition: file.h:384
oslFileError
Definition: file.h:85
static RC createPath(const ::rtl::OUString &aDirectoryUrl, DirectoryCreationObserver *aDirectoryCreationObserver=NULL)
Create a directory path.
Definition: file.hxx:1901
SAL_DLLPUBLIC oslFileError osl_getCanonicalName(rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL)
Determine a valid unused canonical name for a requested name.
SAL_WARN_UNUSED_RESULT RC setPos(sal_uInt32 uHow, sal_Int64 uPos)
Set the internal position pointer of an open file.
Definition: file.hxx:1018
Definition: file.h:91
RC readLine(::rtl::ByteSequence &aSeq)
Read a line from a file.
Definition: file.hxx:1213
Definition: bootstrap.hxx:29
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath,::rtl::OUString &ustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.hxx:204
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:821
Definition: file.h:128
Definition: file.h:114
#define osl_FileStatus_Mask_FileName
Definition: file.h:366
SAL_DLLPUBLIC oslFileError osl_acquireVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Acquire a volume device handle.
RC close()
Close a directory.
Definition: file.hxx:1691
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1268
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:394
Definition: file.h:329
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:123
SAL_DLLPUBLIC oslFileError osl_releaseDirectoryItem(oslDirectoryItem Item)
Decrease the refcount of a directory item handle.
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:510
Type getFileType() const
Get the file type.
Definition: file.hxx:705
Definition: time.h:66
SAL_DLLPUBLIC sal_Bool osl_identicalDirectoryItem(oslDirectoryItem pItemA, oslDirectoryItem pItemB)
Determine if two directory items point the same underlying file.
::rtl::OUString getFileSystemName() const
Determine the name of the volume device&#39;s File System.
Definition: file.hxx:582
C++ class representing a SAL byte sequence.
Definition: byteseq.h:165
Definition: file.h:92
RC isEndOfFile(sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:1064
Definition: file.h:116
#define osl_Volume_Attribute_RAMDisk
Definition: file.h:528
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1110
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1573
The directory class object provides a enumeration of DirectoryItems.
Definition: file.hxx:1601
void * oslFileHandle
Definition: file.h:626
SAL_DLLPUBLIC oslFileError osl_readFile(oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead)
Read a number of bytes from a file.
sal_uInt64 getUsedSpace() const
Determine the used space of a volume device.
Definition: file.hxx:546
SAL_DLLPUBLIC oslFileError osl_acquireDirectoryItem(oslDirectoryItem Item)
Increase the refcount of a directory item handle.
Structure containing information about volumes.
Definition: file.h:560
bool isCaseSensitiveFileSystem() const
Return whether the file system is case sensitive or case insensitive.
Definition: file.hxx:606
Definition: file.h:90
The VolumeDevice class.
Definition: file.hxx:320
SAL_DLLPUBLIC oslFileError osl_syncFile(oslFileHandle Handle)
Synchronize the memory representation of a file with that on the physical medium. ...
static RC getVolumeInfo(const ::rtl::OUString &ustrDirectoryURL, VolumeInfo &rInfo)
Retrieve information about a volume.
Definition: file.hxx:1790
Definition: file.h:106
Definition: file.h:98
Definition: file.h:127
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1086
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1237
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
SAL_DLLPUBLIC oslFileError osl_getDirectoryItem(rtl_uString *pustrFileURL, oslDirectoryItem *pItem)
Retrieve a single directory item.
~FileStatus()
Destructor.
Definition: file.hxx:676
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:389
Definition: file.h:332
Definition: file.h:101
The FileStatus class.
Definition: file.hxx:634
Definition: file.h:113
#define osl_FileStatus_Mask_Type
Definition: file.h:360
Definition: condition.hxx:28
SAL_DLLPUBLIC oslFileError osl_createTempFile(rtl_uString *pustrDirectoryURL, oslFileHandle *pHandle, rtl_uString **ppustrTempFileURL)
Creates a temporary file in the directory provided by the caller or the directory returned by osl_get...
Definition: file.h:94
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:399
Definition: file.h:100
Definition: file.h:129
~DirectoryItem()
Destructor.
Definition: file.hxx:1421
Definition: file.h:104
~VolumeDevice()
Destructor.
Definition: file.hxx:349
sal_uInt64 uTotalSpace
Total available space on the volume for the current process/user.
Definition: file.h:569
Definition: file.h:326
bool getRemoveableFlag() const
Check the removable flag.
Definition: file.hxx:466
~VolumeInfo()
Definition: file.hxx:433
Definition: file.h:133
::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:868
~File()
Destructor.
Definition: file.hxx:915
Definition: socket_decl.hxx:191
Definition: file.h:117
static RC getCanonicalName(const ::rtl::OUString &ustrRequestedURL,::rtl::OUString &ustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.hxx:127
sal_uInt64 getTotalSpace() const
Determine the total space of a volume device.
Definition: file.hxx:522
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1412
#define osl_FileStatus_Mask_FileSize
Definition: file.h:365
SAL_DLLPUBLIC oslFileError osl_moveFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Move a file or directory to a new destination or renames it.
#define osl_Volume_Attribute_Remote
Definition: file.h:525
SAL_DLLPUBLIC oslFileError osl_copyFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Copy a file to a new destination.
#define osl_FileStatus_Mask_AccessTime
Definition: file.h:363
SAL_DLLPUBLIC oslFileError osl_getAbsoluteFileURL(rtl_uString *pustrBaseDirectoryURL, rtl_uString *pustrRelativeFileURL, rtl_uString **ppustrAbsoluteFileURL)
Convert a path relative to a given directory into an full qualified file URL.
Structure containing information about files and directories.
Definition: file.h:378
static RC setAttributes(const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:1348
Definition: file.h:105