LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <cassert>
28 #include <cstddef>
29 
30 #include <sal/log.hxx>
31 #include <osl/time.h>
32 #include <rtl/ustring.hxx>
33 
34 #include <osl/file.h>
35 #include <osl/diagnose.h>
36 #include <rtl/byteseq.hxx>
37 
38 #include <stdio.h>
39 
40 namespace osl
41 {
42 
43 
51 class FileBase
52 {
53 public:
54 
55  enum RC {
101  E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
104  };
105 
106 
107 public:
108 
130  static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
131  {
132  return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
133  }
134 
170  static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
171  {
172  return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
173  }
174 
190  static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
191  {
192  return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
193  }
194 
210  static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
211  {
212  return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
213  }
214 
243  static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
244  {
245  return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
246  }
247 
258  static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
259  {
260  return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
261  }
262 
311  static inline RC createTempFile(
312  ::rtl::OUString* pustrDirectoryURL,
313  oslFileHandle* pHandle,
314  ::rtl::OUString* pustrTempFileURL)
315  {
316  rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : NULL;
317  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : NULL;
318 
319  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
320  }
321 };
322 
323 
329 class VolumeDevice : public FileBase
330 {
331  oslVolumeDeviceHandle _aHandle;
332 
333 public:
334 
338  VolumeDevice() : _aHandle( NULL )
339  {
340  }
341 
348  VolumeDevice( const VolumeDevice & rDevice )
349  {
350  _aHandle = rDevice._aHandle;
351  if ( _aHandle )
352  osl_acquireVolumeDeviceHandle( _aHandle );
353  }
354 
359  {
360  if ( _aHandle )
361  osl_releaseVolumeDeviceHandle( _aHandle );
362  }
363 
370  inline VolumeDevice & operator =( const VolumeDevice & rDevice )
371  {
372  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
373 
374  if ( newHandle )
375  osl_acquireVolumeDeviceHandle( newHandle );
376 
377  if ( _aHandle )
378  osl_releaseVolumeDeviceHandle( _aHandle );
379 
380  _aHandle = newHandle;
381 
382  return *this;
383  }
384 
391  {
392  rtl::OUString aPath;
393  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
394  return aPath;
395  }
396 
397  friend class VolumeInfo;
398 };
399 
400 
401 class Directory;
402 
412 {
413  oslVolumeInfo _aInfo;
414  sal_uInt32 _nMask;
415  VolumeDevice _aDevice;
416 
421 
425  VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
426 
427 public:
428 
435  VolumeInfo( sal_uInt32 nMask )
436  : _nMask( nMask )
437  {
438  memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
439  _aInfo.uStructSize = sizeof( oslVolumeInfo );
440  _aInfo.pDeviceHandle = &_aDevice._aHandle;
441  }
442 
447  {
448  if( _aInfo.ustrFileSystemName )
450  }
451 
460  inline bool isValid( sal_uInt32 nMask ) const
461  {
462  return ( nMask & _aInfo.uValidFields ) == nMask;
463  }
464 
471  inline bool getRemoteFlag() const
472  {
473  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
474  }
475 
482  inline bool getRemoveableFlag() const
483  {
484  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
485  }
486 
493  inline bool getCompactDiscFlag() const
494  {
495  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
496  }
497 
504  inline bool getFloppyDiskFlag() const
505  {
506  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
507  }
508 
515  inline bool getFixedDiskFlag() const
516  {
517  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
518  }
519 
526  inline bool getRAMDiskFlag() const
527  {
528  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
529  }
530 
538  inline sal_uInt64 getTotalSpace() const
539  {
540  return _aInfo.uTotalSpace;
541  }
542 
550  inline sal_uInt64 getFreeSpace() const
551  {
552  return _aInfo.uFreeSpace;
553  }
554 
562  inline sal_uInt64 getUsedSpace() const
563  {
564  return _aInfo.uUsedSpace;
565  }
566 
574  inline sal_uInt32 getMaxNameLength() const
575  {
576  return _aInfo.uMaxNameLength;
577  }
578 
586  inline sal_uInt32 getMaxPathLength() const
587  {
588  return _aInfo.uMaxPathLength;
589  }
590 
598  inline ::rtl::OUString getFileSystemName() const
599  {
601  }
602 
603 
612  {
613  return _aDevice;
614  }
615 
623  {
624  return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
625  }
626 
635  {
637  }
638 
639  friend class Directory;
640 };
641 
642 
643 class DirectoryItem;
644 
651 {
652  oslFileStatus _aStatus;
653  sal_uInt32 _nMask;
654 
659 
663  FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
664 
665 public:
666 
667  enum Type {
676  };
677 
683  FileStatus(sal_uInt32 nMask)
684  : _nMask(nMask)
685  {
686  memset(&_aStatus, 0, sizeof(_aStatus));
687  _aStatus.uStructSize = sizeof(_aStatus);
688  }
689 
693  {
694  if ( _aStatus.ustrFileURL )
695  rtl_uString_release( _aStatus.ustrFileURL );
696  if ( _aStatus.ustrLinkTargetURL )
698  if ( _aStatus.ustrFileName )
699  rtl_uString_release( _aStatus.ustrFileName );
700  }
701 
711  inline bool isValid( sal_uInt32 nMask ) const
712  {
713  return ( nMask & _aStatus.uValidFields ) == nMask;
714  }
715 
721  inline Type getFileType() const
722  {
723  SAL_INFO_IF(
724  !isValid(osl_FileStatus_Mask_Type), "sal.osl",
725  "no FileStatus Type determined");
727  ? static_cast< Type >(_aStatus.eType) : Unknown;
728  }
729 
739  inline bool isDirectory() const
740  {
741  return ( getFileType() == Directory || getFileType() == Volume );
742  }
743 
754  inline bool isRegular() const
755  {
756  return ( getFileType() == Regular );
757  }
758 
767  inline bool isLink() const
768  {
769  return ( getFileType() == Link );
770  }
771 
778  inline sal_uInt64 getAttributes() const
779  {
780  SAL_INFO_IF(
782  "no FileStatus Attributes determined");
783  return _aStatus.uAttributes;
784  }
785 
793  inline TimeValue getCreationTime() const
794  {
795  SAL_INFO_IF(
797  "no FileStatus CreationTime determined");
798  return _aStatus.aCreationTime;
799  }
800 
808  inline TimeValue getAccessTime() const
809  {
810  SAL_INFO_IF(
812  "no FileStatus AccessTime determined");
813  return _aStatus.aAccessTime;
814  }
815 
823  inline TimeValue getModifyTime() const
824  {
825  SAL_INFO_IF(
827  "no FileStatus ModifyTime determined");
828  return _aStatus.aModifyTime;
829  }
830 
837  inline sal_uInt64 getFileSize() const
838  {
839  SAL_INFO_IF(
841  "no FileStatus FileSize determined");
842  return _aStatus.uFileSize;
843  }
844 
851  inline ::rtl::OUString getFileName() const
852  {
853  SAL_INFO_IF(
855  "no FileStatus FileName determined");
857  ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
858  }
859 
860 
868  inline ::rtl::OUString getFileURL() const
869  {
870  SAL_INFO_IF(
872  "no FileStatus FileURL determined");
874  ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
875  }
876 
884  inline ::rtl::OUString getLinkTargetURL() const
885  {
886  SAL_INFO_IF(
888  "no FileStatus LinkTargetURL determined");
891  }
892 
893  friend class DirectoryItem;
894 };
895 
896 
903 class File: public FileBase
904 {
905  oslFileHandle _pData;
906  ::rtl::OUString _aPath;
907 
912 
916  File& operator = ( File& ) SAL_DELETED_FUNCTION;
917 
918 public:
919 
926  File( const ::rtl::OUString& ustrFileURL ): _pData( NULL ), _aPath( ustrFileURL ) {}
927 
931  inline ~File()
932  {
933  close();
934  }
935 
943  inline rtl::OUString getURL() const { return _aPath; }
944 
988  inline RC open( sal_uInt32 uFlags )
989  {
990  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
991  }
992 
1007  inline RC close()
1008  {
1009  oslFileError Error = osl_File_E_BADF;
1010 
1011  if( _pData )
1012  {
1013  Error=osl_closeFile( _pData );
1014  _pData = NULL;
1015  }
1016 
1017  return static_cast< RC >( Error );
1018  }
1019 
1037  inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1038  {
1039  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1040  }
1041 
1058  inline RC getPos( sal_uInt64& uPos )
1059  {
1060  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1061  }
1062 
1085  inline RC isEndOfFile( sal_Bool *pIsEOF )
1086  {
1087  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1088  }
1089 
1108  inline RC setSize( sal_uInt64 uSize )
1109  {
1110  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1111  }
1112 
1133  inline RC getSize( sal_uInt64 &rSize )
1134  {
1135  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1136  }
1137 
1170  inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1171  {
1172  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1173  }
1174 
1209  inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1210  {
1211  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1212  }
1213 
1214 
1239  inline RC readLine( ::rtl::ByteSequence& aSeq )
1240  {
1241  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1242  }
1243 
1274  inline RC sync() const
1275  {
1276  OSL_PRECOND(_pData, "File::sync(): File not open");
1277  return static_cast< RC >(osl_syncFile(_pData));
1278  }
1279 
1306  inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1307  {
1308  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1309  }
1310 
1335  inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1336  {
1337  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1338  }
1339 
1368  inline static RC remove( const ::rtl::OUString& ustrFileURL )
1369  {
1370  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1371  }
1372 
1388  inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1389  {
1390  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1391  }
1392 
1415  inline static RC setTime(
1416  const ::rtl::OUString& ustrFileURL,
1417  const TimeValue& rCreationTime,
1418  const TimeValue& rLastAccessTime,
1419  const TimeValue& rLastWriteTime )
1420  {
1421  return static_cast< RC >( osl_setFileTime(
1422  ustrFileURL.pData,
1423  &rCreationTime,
1424  &rLastAccessTime,
1425  &rLastWriteTime ) );
1426  }
1427 
1428  friend class DirectoryItem;
1429 };
1430 
1431 
1438 {
1439  oslDirectoryItem _pData;
1440 
1441 public:
1442 
1446  DirectoryItem(): _pData( NULL )
1447  {
1448  }
1449 
1453  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1454  {
1455  if( _pData )
1456  osl_acquireDirectoryItem( _pData );
1457  }
1458 
1463  {
1464  if( _pData )
1465  osl_releaseDirectoryItem( _pData );
1466  }
1467 
1472  {
1473  if (&rItem != this)
1474  {
1475  if( _pData )
1476  osl_releaseDirectoryItem( _pData );
1477 
1478  _pData = rItem._pData;
1479 
1480  if( _pData )
1481  osl_acquireDirectoryItem( _pData );
1482  }
1483  return *this;
1484  }
1485 
1492  inline bool is()
1493  {
1494  return _pData != NULL;
1495  }
1496 
1531  static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1532  {
1533  if( rItem._pData)
1534  {
1535  osl_releaseDirectoryItem( rItem._pData );
1536  rItem._pData = NULL;
1537  }
1538 
1539  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1540  }
1541 
1574  inline RC getFileStatus( FileStatus& rStatus )
1575  {
1576  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1577  }
1578 
1595  inline bool isIdenticalTo( const DirectoryItem &pOther )
1596  {
1597  return osl_identicalDirectoryItem( _pData, pOther._pData );
1598  }
1599 
1600  friend class Directory;
1601 };
1602 
1603 
1615 {
1616 public:
1618 
1628  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1629 };
1630 
1631 
1632 // This just an internal helper function for
1633 // private use.
1634 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1635 {
1636  (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1637 }
1638 
1645 class Directory: public FileBase
1646 {
1647  oslDirectory _pData;
1648  ::rtl::OUString _aPath;
1649 
1654 
1658  Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1659 
1660 public:
1661 
1669  Directory( const ::rtl::OUString& strPath ): _pData( NULL ), _aPath( strPath )
1670  {
1671  }
1672 
1677  {
1678  close();
1679  }
1680 
1688  inline rtl::OUString getURL() const { return _aPath; }
1689 
1708  inline RC open()
1709  {
1710  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1711  }
1712 
1724  inline bool isOpen() { return _pData != NULL; }
1725 
1738  inline RC close()
1739  {
1740  oslFileError Error = osl_File_E_BADF;
1741 
1742  if( _pData )
1743  {
1744  Error=osl_closeDirectory( _pData );
1745  _pData = NULL;
1746  }
1747 
1748  return static_cast< RC >( Error );
1749  }
1750 
1751 
1769  inline RC reset()
1770  {
1771  close();
1772  return open();
1773  }
1774 
1798  inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1799  {
1800  if( rItem._pData )
1801  {
1802  osl_releaseDirectoryItem( rItem._pData );
1803  rItem._pData = NULL;
1804  }
1805  return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1806  }
1807 
1808 
1840  inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1841  {
1842  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1843  }
1844 
1876  inline static RC create(
1877  const ::rtl::OUString& ustrDirectoryURL,
1878  sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1879  {
1880  return static_cast< RC >(
1881  osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1882  }
1883 
1912  inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1913  {
1914  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1915  }
1916 
1969  static RC createPath(
1970  const ::rtl::OUString& aDirectoryUrl,
1971  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1972  {
1973  return static_cast< RC >(osl_createDirectoryPath(
1974  aDirectoryUrl.pData,
1975  (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1976  aDirectoryCreationObserver));
1977  }
1978 };
1979 
1980 } /* namespace osl */
1981 
1982 #endif // INCLUDED_OSL_FILE_HXX
1983 
1984 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 uFreeSpace
Free space on the volume for the current process/user.
Definition: file.h:580
Definition: file.hxx:90
Definition: file.h:124
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1798
Definition: file.h:112
#define osl_Volume_Attribute_RAMDisk
Definition: file.h:542
inline::rtl::OUString getFileSystemName() const
Determine the name of the volume device&#39;s File System.
Definition: file.hxx:598
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:572
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:374
Definition: file.h:104
#define SAL_INFO_IF(condition, area, stream)
Produce log entry from stream in the given log area if condition is true.
Definition: log.hxx:303
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:390
bool isRegular() const
Is it a regular file?
Definition: file.hxx:754
Definition: file.hxx:57
Definition: file.hxx:92
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
Definition: file.h:133
Definition: file.hxx:669
Definition: file.hxx:99
#define osl_FileStatus_Mask_Type
Definition: file.h:366
sal_uInt32 uMaxPathLength
Maximum length of a full quallified path in system notation.
Definition: file.h:584
#define osl_File_OpenFlag_Read
Definition: file.h:638
#define osl_Volume_Attribute_Remote
Definition: file.h:539
Definition: file.hxx:94
sal_uInt32 uMaxNameLength
Maximum length of file name of a single item.
Definition: file.h:582
Definition: file.h:132
Definition: file.h:94
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:943
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:570
Base class for all File System specific objects.
Definition: file.hxx:51
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:988
Type
Definition: file.hxx:667
static RC getSystemPathFromFileURL(const ::rtl::OUString &ustrFileURL,::rtl::OUString &ustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:190
#define osl_FileStatus_Mask_AccessTime
Definition: file.h:369
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:1335
Definition: file.hxx:59
Definition: file.h:121
Definition: file.hxx:95
SAL_DLLPUBLIC oslFileError osl_getFileURLFromSystemPath(rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.h:109
#define osl_FileStatus_Mask_FileSize
Definition: file.h:371
Definition: file.h:120
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:311
VolumeDevice & operator=(const VolumeDevice &rDevice)
Assignment operator.
Definition: file.hxx:370
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:1415
Definition: file.hxx:63
Definition: file.h:88
Definition: file.h:97
Definition: file.hxx:61
Definition: file.hxx:67
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:389
sal_uInt64 uFileSize
Size in bytes of the file.
Definition: file.h:405
SAL_DLLPUBLIC oslFileError osl_releaseVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Release a volume device handle.
Definition: file.hxx:93
Definition: file.hxx:84
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1634
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:823
#define osl_FileStatus_Mask_Attributes
Definition: file.h:367
~Directory()
Destructor.
Definition: file.hxx:1676
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:711
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1708
The directory item class object provides access to file status information.
Definition: file.hxx:1437
Definition: file.hxx:74
#define osl_Volume_Attribute_Removeable
Definition: file.h:538
Definition: file.h:110
bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:515
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:170
void * oslDirectory
Definition: file.h:138
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:550
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:1209
struct _oslVolumeInfo oslVolumeInfo
bool isLink() const
Is it a link?
Definition: file.hxx:767
Definition: file.h:343
Definition: file.h:98
static RC getTempDirURL(::rtl::OUString &ustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
Definition: file.hxx:258
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:435
rtl_uString * ustrFileSystemName
Points to a string that receives the name of the file system type.
Definition: file.h:587
Definition: file.h:119
bool getRemoteFlag() const
Check the remote flag.
Definition: file.hxx:471
Definition: file.hxx:58
Definition: file.hxx:75
#define osl_Volume_Attribute_Case_Sensitive
Definition: file.h:546
Definition: file.h:111
bool getFloppyDiskFlag() const
Check the floppy disc flag.
Definition: file.hxx:504
Definition: file.h:127
Definition: file.h:87
#define osl_Volume_Attribute_FloppyDisk
Definition: file.h:543
FileStatus(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:683
Definition: file.hxx:86
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
Definition: file.hxx:89
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:348
Definition: file.hxx:98
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1574
Definition: file.hxx:68
Definition: file.h:116
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:778
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:1492
Definition: file.hxx:56
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:574
RC close()
Close an open file.
Definition: file.hxx:1007
oslVolumeDeviceHandle * pDeviceHandle
Pointer to handle the receives underlying device.
Definition: file.h:589
Main goals and usage hints.
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:1688
Definition: file.h:100
RC setPos(sal_uInt32 uHow, sal_Int64 uPos) SAL_WARN_UNUSED_RESULT
Set the internal position pointer of an open file.
Definition: file.hxx:1037
Definition: file.h:122
Definition: file.hxx:671
Definition: file.hxx:103
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1058
unsigned char sal_Bool
Definition: types.h:48
#define osl_Volume_Attribute_FixedDisk
Definition: file.h:541
static RC create(const ::rtl::OUString &ustrDirectoryURL, sal_uInt32 flags=osl_File_OpenFlag_Read|osl_File_OpenFlag_Write)
Create a directory.
Definition: file.hxx:1876
Definition: file.hxx:62
VolumeDevice()
Constructor.
Definition: file.hxx:338
Base class for observers of directory creation notifications.
Definition: file.hxx:1614
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1669
Definition: file.hxx:675
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:793
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:926
Definition: file.hxx:88
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1471
rtl_uString * ustrFileURL
Full URL of the file.
Definition: file.h:411
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:411
Definition: file.h:108
The file class object provides access to file contents and attributes.
Definition: file.hxx:903
bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1595
virtual void DirectoryCreated(const rtl::OUString &aDirectoryUrl)=0
This method will be called when a new directory has been created and needs to be overwritten by deriv...
Definition: file.h:96
TimeValue aAccessTime
Last access time in nanoseconds since 1/1/1970.
Definition: file.h:401
inline::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:884
#define OSL_PRECOND(c, m)
Definition: diagnose.h:105
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:586
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
inline::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:868
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.
Definition: file.hxx:73
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:611
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:808
RC
Definition: file.hxx:55
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:574
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:325
Definition: file.h:89
Definition: file.hxx:670
SAL_DLLPUBLIC oslFileError osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:77
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:66
Definition: file.hxx:102
Definition: file.h:90
Definition: file.hxx:96
SAL_DLLPUBLIC oslFileError osl_openDirectory(rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory)
Open a directory for enumerating its contents.
Definition: file.h:125
Definition: file.h:123
bool getCompactDiscFlag() const
Check the compact disc flag.
Definition: file.hxx:493
DirectoryItem()
Constructor.
Definition: file.hxx:1446
Definition: file.h:345
bool isCasePreservingFileSystem() const
Return whether the file system preserves the case of file and directory names or not.
Definition: file.hxx:634
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:460
void * oslDirectoryItem
Definition: file.h:139
SAL_DLLPUBLIC oslFileError osl_searchFileURL(rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL)
Searche 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:391
SAL_DLLPUBLIC oslFileError osl_openFile(rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags)
Open a regular file.
void * oslVolumeDeviceHandle
Definition: file.h:462
rtl_uString * ustrLinkTargetURL
Full URL of the target file if the file itself is a link.
Definition: file.h:415
bool isOpen()
Query if directory is open.
Definition: file.hxx:1724
#define osl_File_OpenFlag_Write
Definition: file.h:639
Definition: file.h:126
RC reset()
Resets the directory item enumeration to the beginning.
Definition: file.hxx:1769
Definition: file.h:113
Definition: file.h:103
Definition: file.h:131
sal_uInt64 uAttributes
File attributes.
Definition: file.h:395
bool isDirectory() const
Is it a directory? This method returns True for both directories, and volumes.
Definition: file.hxx:739
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:243
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1170
SAL_DLLPUBLIC oslFileError osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos) SAL_WARN_UNUSED_RESULT
Set the internal position pointer of an open file.
sal_uInt64 uUsedSpace
Used space on the volume for the current process/user.
Definition: file.h:578
Definition: file.hxx:64
oslFileType eType
The type of the file (file, directory, volume).
Definition: file.h:393
oslFileError
Definition: file.h:86
#define osl_FileStatus_Mask_FileName
Definition: file.h:372
static RC createPath(const ::rtl::OUString &aDirectoryUrl, DirectoryCreationObserver *aDirectoryCreationObserver=NULL)
Create a directory path.
Definition: file.hxx:1969
Definition: file.hxx:91
Definition: file.hxx:70
SAL_DLLPUBLIC oslFileError osl_getCanonicalName(rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.h:92
RC readLine(::rtl::ByteSequence &aSeq)
Read a line from a file.
Definition: file.hxx:1239
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath,::rtl::OUString &ustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.hxx:210
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:837
Definition: file.h:129
#define osl_FileStatus_Mask_ModifyTime
Definition: file.h:370
Definition: file.h:115
SAL_DLLPUBLIC oslFileError osl_acquireVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Acquire a volume device handle.
RC close()
Close a directory.
Definition: file.hxx:1738
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1306
Definition: file.h:346
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:403
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
#define osl_Volume_Attribute_CompactDisc
Definition: file.h:540
SAL_DLLPUBLIC oslFileError osl_releaseDirectoryItem(oslDirectoryItem Item)
Decrease the refcount of a directory item handle.
Definition: file.hxx:60
Definition: file.hxx:78
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
Definition: file.hxx:69
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:545
bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:526
Type getFileType() const
Get the file type.
Definition: file.hxx:721
Definition: time.h:70
SAL_DLLPUBLIC sal_Bool osl_identicalDirectoryItem(oslDirectoryItem pItemA, oslDirectoryItem pItemB)
Determine if two directory items point the same underlying file.
C++ class representing a SAL byte sequence.
Definition: byteseq.h:165
Definition: file.h:93
Definition: file.h:341
RC isEndOfFile(sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:1085
inline::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:851
Definition: file.h:117
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1133
Definition: file.hxx:72
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1617
Definition: file.hxx:82
The directory class object provides a enumeration of DirectoryItems.
Definition: file.hxx:1645
void * oslFileHandle
Definition: file.h:634
Definition: file.hxx:85
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:562
SAL_DLLPUBLIC oslFileError osl_acquireDirectoryItem(oslDirectoryItem Item)
Increase the refcount of a directory item handle.
Structure containing information about volumes.
Definition: file.h:568
bool isCaseSensitiveFileSystem() const
Return whether the file system is case sensitive or case insensitive.
Definition: file.hxx:622
Definition: file.h:91
Definition: file.hxx:87
The VolumeDevice class.
Definition: file.hxx:329
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:1840
Definition: file.h:107
Definition: file.hxx:80
Definition: file.h:99
Definition: file.h:128
Definition: file.hxx:97
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1108
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1274
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
Definition: file.hxx:100
SAL_DLLPUBLIC oslFileError osl_getDirectoryItem(rtl_uString *pustrFileURL, oslDirectoryItem *pItem)
Retrieve a single directory item.
#define osl_FileStatus_Mask_CreationTime
Definition: file.h:368
~FileStatus()
Destructor.
Definition: file.hxx:692
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:398
Definition: file.hxx:81
Definition: file.h:342
Definition: file.h:102
Definition: file.h:340
Definition: file.hxx:101
The FileStatus class.
Definition: file.hxx:650
Definition: file.h:114
Definition: file.hxx:71
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.hxx:65
Definition: file.h:95
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:408
Definition: file.h:101
Definition: file.h:130
~DirectoryItem()
Destructor.
Definition: file.hxx:1462
Definition: file.hxx:673
Definition: file.h:105
~VolumeDevice()
Destructor.
Definition: file.hxx:358
sal_uInt64 uTotalSpace
Total available space on the volume for the current process/user.
Definition: file.h:576
bool getRemoveableFlag() const
Check the removeable flag.
Definition: file.hxx:482
Definition: file.hxx:76
#define osl_FileStatus_Mask_FileURL
Definition: file.h:373
~VolumeInfo()
Destructor.
Definition: file.hxx:446
Definition: file.h:134
Definition: file.hxx:79
~File()
Destructor.
Definition: file.hxx:931
Definition: socket_decl.hxx:174
Definition: file.hxx:674
Definition: file.h:118
static RC getCanonicalName(const ::rtl::OUString &ustrRequestedURL,::rtl::OUString &ustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.hxx:130
sal_uInt64 getTotalSpace() const
Determine the total space of a volume device.
Definition: file.hxx:538
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1453
SAL_DLLPUBLIC oslFileError osl_moveFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Move a file or directory to a new destination or renames it.
Definition: file.h:347
SAL_DLLPUBLIC oslFileError osl_copyFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Copy a file to a new destination.
Definition: file.h:344
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.
Definition: file.hxx:83
Structure containing information about files and directories.
Definition: file.h:387
static RC setAttributes(const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:1388
Definition: file.h:106