LibreOffice
LibreOffice 5.1 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 <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 
44 
52 class FileBase
53 {
54 public:
55 
56  enum RC {
102  E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
105  };
106 
107 
108 public:
109 
131  static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
132  {
133  return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
134  }
135 
171  static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
172  {
173  return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
174  }
175 
191  static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
192  {
193  return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
194  }
195 
211  static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
212  {
213  return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
214  }
215 
244  static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
245  {
246  return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
247  }
248 
259  static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
260  {
261  return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
262  }
263 
312  static inline RC createTempFile(
313  ::rtl::OUString* pustrDirectoryURL,
314  oslFileHandle* pHandle,
315  ::rtl::OUString* pustrTempFileURL)
316  {
317  rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : NULL;
318  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : NULL;
319 
320  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
321  }
322 };
323 
324 
325 
331 class VolumeDevice : public FileBase
332 {
333  oslVolumeDeviceHandle _aHandle;
334 
335 public:
336 
340  VolumeDevice() : _aHandle( NULL )
341  {
342  }
343 
350  VolumeDevice( const VolumeDevice & rDevice )
351  {
352  _aHandle = rDevice._aHandle;
353  if ( _aHandle )
354  osl_acquireVolumeDeviceHandle( _aHandle );
355  }
356 
361  {
362  if ( _aHandle )
363  osl_releaseVolumeDeviceHandle( _aHandle );
364  }
365 
372  inline VolumeDevice & operator =( const VolumeDevice & rDevice )
373  {
374  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
375 
376  if ( newHandle )
377  osl_acquireVolumeDeviceHandle( newHandle );
378 
379  if ( _aHandle )
380  osl_releaseVolumeDeviceHandle( _aHandle );
381 
382  _aHandle = newHandle;
383 
384  return *this;
385  }
386 
393  {
394  rtl::OUString aPath;
395  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
396  return aPath;
397  }
398 
399  friend class VolumeInfo;
400 };
401 
402 
403 
404 class Directory;
405 
415 {
416  oslVolumeInfo _aInfo;
417  sal_uInt32 _nMask;
418  VolumeDevice _aDevice;
419 
424 
428  VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
429 
430 public:
431 
438  VolumeInfo( sal_uInt32 nMask )
439  : _nMask( nMask )
440  {
441  memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
442  _aInfo.uStructSize = sizeof( oslVolumeInfo );
443  _aInfo.pDeviceHandle = &_aDevice._aHandle;
444  }
445 
450  {
451  if( _aInfo.ustrFileSystemName )
453  }
454 
463  inline bool isValid( sal_uInt32 nMask ) const
464  {
465  return ( nMask & _aInfo.uValidFields ) == nMask;
466  }
467 
474  inline bool getRemoteFlag() const
475  {
476  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
477  }
478 
485  inline bool getRemoveableFlag() const
486  {
487  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
488  }
489 
496  inline bool getCompactDiscFlag() const
497  {
498  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
499  }
500 
507  inline bool getFloppyDiskFlag() const
508  {
509  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
510  }
511 
518  inline bool getFixedDiskFlag() const
519  {
520  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
521  }
522 
529  inline bool getRAMDiskFlag() const
530  {
531  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
532  }
533 
541  inline sal_uInt64 getTotalSpace() const
542  {
543  return _aInfo.uTotalSpace;
544  }
545 
553  inline sal_uInt64 getFreeSpace() const
554  {
555  return _aInfo.uFreeSpace;
556  }
557 
565  inline sal_uInt64 getUsedSpace() const
566  {
567  return _aInfo.uUsedSpace;
568  }
569 
577  inline sal_uInt32 getMaxNameLength() const
578  {
579  return _aInfo.uMaxNameLength;
580  }
581 
589  inline sal_uInt32 getMaxPathLength() const
590  {
591  return _aInfo.uMaxPathLength;
592  }
593 
601  inline ::rtl::OUString getFileSystemName() const
602  {
604  }
605 
606 
615  {
616  return _aDevice;
617  }
618 
626  {
627  return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
628  }
629 
638  {
640  }
641 
642  friend class Directory;
643 };
644 
645 
646 class DirectoryItem;
647 
654 {
655  oslFileStatus _aStatus;
656  sal_uInt32 _nMask;
657 
662 
666  FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
667 
668 public:
669 
670  enum Type {
679  };
680 
686  FileStatus(sal_uInt32 nMask)
687  : _nMask(nMask)
688  {
689  memset(&_aStatus, 0, sizeof(_aStatus));
690  _aStatus.uStructSize = sizeof(_aStatus);
691  }
692 
696  {
697  if ( _aStatus.ustrFileURL )
698  rtl_uString_release( _aStatus.ustrFileURL );
699  if ( _aStatus.ustrLinkTargetURL )
701  if ( _aStatus.ustrFileName )
702  rtl_uString_release( _aStatus.ustrFileName );
703  }
704 
714  inline bool isValid( sal_uInt32 nMask ) const
715  {
716  return ( nMask & _aStatus.uValidFields ) == nMask;
717  }
718 
724  inline Type getFileType() const
725  {
726  SAL_INFO_IF(
727  !isValid(osl_FileStatus_Mask_Type), "sal.osl",
728  "no FileStatus Type determined");
729  return isValid(osl_FileStatus_Mask_Type)
730  ? static_cast< Type >(_aStatus.eType) : Unknown;
731  }
732 
742  inline bool isDirectory() const
743  {
744  return ( getFileType() == Directory || getFileType() == Volume );
745  }
746 
757  inline bool isRegular() const
758  {
759  return ( getFileType() == Regular );
760  }
761 
770  inline bool isLink() const
771  {
772  return ( getFileType() == Link );
773  }
774 
781  inline sal_uInt64 getAttributes() const
782  {
783  SAL_INFO_IF(
784  !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
785  "no FileStatus Attributes determined");
786  return _aStatus.uAttributes;
787  }
788 
796  inline TimeValue getCreationTime() const
797  {
798  SAL_INFO_IF(
799  !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
800  "no FileStatus CreationTime determined");
801  return _aStatus.aCreationTime;
802  }
803 
811  inline TimeValue getAccessTime() const
812  {
813  SAL_INFO_IF(
814  !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
815  "no FileStatus AccessTime determined");
816  return _aStatus.aAccessTime;
817  }
818 
826  inline TimeValue getModifyTime() const
827  {
828  SAL_INFO_IF(
829  !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
830  "no FileStatus ModifyTime determined");
831  return _aStatus.aModifyTime;
832  }
833 
840  inline sal_uInt64 getFileSize() const
841  {
842  SAL_INFO_IF(
843  !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
844  "no FileStatus FileSize determined");
845  return _aStatus.uFileSize;
846  }
847 
854  inline ::rtl::OUString getFileName() const
855  {
856  SAL_INFO_IF(
857  !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
858  "no FileStatus FileName determined");
859  return isValid(osl_FileStatus_Mask_FileName)
860  ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
861  }
862 
863 
871  inline ::rtl::OUString getFileURL() const
872  {
873  SAL_INFO_IF(
874  !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
875  "no FileStatus FileURL determined");
876  return isValid(osl_FileStatus_Mask_FileURL)
877  ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
878  }
879 
887  inline ::rtl::OUString getLinkTargetURL() const
888  {
889  SAL_INFO_IF(
890  !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
891  "no FileStatus LinkTargetURL determined");
892  return isValid(osl_FileStatus_Mask_LinkTargetURL)
894  }
895 
896  friend class DirectoryItem;
897 };
898 
899 
900 
907 class File: public FileBase
908 {
909  oslFileHandle _pData;
910  ::rtl::OUString _aPath;
911 
916 
920  File& operator = ( File& ) SAL_DELETED_FUNCTION;
921 
922 public:
923 
930  File( const ::rtl::OUString& ustrFileURL ): _pData( NULL ), _aPath( ustrFileURL ) {}
931 
935  inline ~File()
936  {
937  close();
938  }
939 
947  inline rtl::OUString getURL() const { return _aPath; }
948 
992  inline RC open( sal_uInt32 uFlags )
993  {
994  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
995  }
996 
1011  inline RC close()
1012  {
1013  oslFileError Error = osl_File_E_BADF;
1014 
1015  if( _pData )
1016  {
1017  Error=osl_closeFile( _pData );
1018  _pData = NULL;
1019  }
1020 
1021  return static_cast< RC >( Error );
1022  }
1023 
1041  inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1042  {
1043  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1044  }
1045 
1062  inline RC getPos( sal_uInt64& uPos )
1063  {
1064  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1065  }
1066 
1089  inline RC isEndOfFile( sal_Bool *pIsEOF )
1090  {
1091  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1092  }
1093 
1112  inline RC setSize( sal_uInt64 uSize )
1113  {
1114  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1115  }
1116 
1137  inline RC getSize( sal_uInt64 &rSize )
1138  {
1139  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1140  }
1141 
1174  inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1175  {
1176  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1177  }
1178 
1213  inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1214  {
1215  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1216  }
1217 
1218 
1243  inline RC readLine( ::rtl::ByteSequence& aSeq )
1244  {
1245  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1246  }
1247 
1278  inline RC sync() const
1279  {
1280  OSL_PRECOND(_pData, "File::sync(): File not open");
1281  return static_cast< RC >(osl_syncFile(_pData));
1282  }
1283 
1310  inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1311  {
1312  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1313  }
1314 
1339  inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1340  {
1341  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1342  }
1343 
1372  inline static RC remove( const ::rtl::OUString& ustrFileURL )
1373  {
1374  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1375  }
1376 
1392  inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1393  {
1394  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1395  }
1396 
1419  inline static RC setTime(
1420  const ::rtl::OUString& ustrFileURL,
1421  const TimeValue& rCreationTime,
1422  const TimeValue& rLastAccessTime,
1423  const TimeValue& rLastWriteTime )
1424  {
1425  return static_cast< RC >( osl_setFileTime(
1426  ustrFileURL.pData,
1427  &rCreationTime,
1428  &rLastAccessTime,
1429  &rLastWriteTime ) );
1430  }
1431 
1432  friend class DirectoryItem;
1433 };
1434 
1435 
1442 {
1443  oslDirectoryItem _pData;
1444 
1445 public:
1446 
1450  DirectoryItem(): _pData( NULL )
1451  {
1452  }
1453 
1457  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1458  {
1459  if( _pData )
1460  osl_acquireDirectoryItem( _pData );
1461  }
1462 
1467  {
1468  if( _pData )
1469  osl_releaseDirectoryItem( _pData );
1470  }
1471 
1476  {
1477  if (&rItem != this)
1478  {
1479  if( _pData )
1480  osl_releaseDirectoryItem( _pData );
1481 
1482  _pData = rItem._pData;
1483 
1484  if( _pData )
1485  osl_acquireDirectoryItem( _pData );
1486  }
1487  return *this;
1488  }
1489 
1496  inline bool is()
1497  {
1498  return _pData != NULL;
1499  }
1500 
1535  static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1536  {
1537  if( rItem._pData)
1538  {
1539  osl_releaseDirectoryItem( rItem._pData );
1540  rItem._pData = NULL;
1541  }
1542 
1543  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1544  }
1545 
1578  inline RC getFileStatus( FileStatus& rStatus )
1579  {
1580  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1581  }
1582 
1599  inline bool isIdenticalTo( const DirectoryItem &pOther )
1600  {
1601  return osl_identicalDirectoryItem( _pData, pOther._pData );
1602  }
1603 
1604  friend class Directory;
1605 };
1606 
1607 
1608 
1620 {
1621 public:
1623 
1633  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1634 };
1635 
1636 
1637 // This just an internal helper function for
1638 // private use.
1639 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1640 {
1641  (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1642 }
1643 
1650 class Directory: public FileBase
1651 {
1652  oslDirectory _pData;
1653  ::rtl::OUString _aPath;
1654 
1659 
1663  Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1664 
1665 public:
1666 
1674  Directory( const ::rtl::OUString& strPath ): _pData( NULL ), _aPath( strPath )
1675  {
1676  }
1677 
1682  {
1683  close();
1684  }
1685 
1693  inline rtl::OUString getURL() const { return _aPath; }
1694 
1713  inline RC open()
1714  {
1715  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1716  }
1717 
1729  inline bool isOpen() { return _pData != NULL; }
1730 
1743  inline RC close()
1744  {
1745  oslFileError Error = osl_File_E_BADF;
1746 
1747  if( _pData )
1748  {
1749  Error=osl_closeDirectory( _pData );
1750  _pData = NULL;
1751  }
1752 
1753  return static_cast< RC >( Error );
1754  }
1755 
1756 
1774  inline RC reset()
1775  {
1776  close();
1777  return open();
1778  }
1779 
1803  inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1804  {
1805  if( rItem._pData )
1806  {
1807  osl_releaseDirectoryItem( rItem._pData );
1808  rItem._pData = NULL;
1809  }
1810  return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1811  }
1812 
1813 
1845  inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1846  {
1847  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1848  }
1849 
1881  inline static RC create(
1882  const ::rtl::OUString& ustrDirectoryURL,
1883  sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1884  {
1885  return static_cast< RC >(
1886  osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1887  }
1888 
1917  inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1918  {
1919  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1920  }
1921 
1974  static RC createPath(
1975  const ::rtl::OUString& aDirectoryUrl,
1976  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1977  {
1978  return static_cast< RC >(osl_createDirectoryPath(
1979  aDirectoryUrl.pData,
1980  (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1981  aDirectoryCreationObserver));
1982  }
1983 };
1984 
1985 } /* namespace osl */
1986 
1987 #endif // INCLUDED_OSL_FILE_HXX
1988 
1989 /* 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:91
Definition: file.h:124
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1803
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:601
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:284
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:392
bool isRegular() const
Is it a regular file?
Definition: file.hxx:757
Definition: file.hxx:58
Definition: file.hxx:93
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
Definition: file.h:133
Definition: file.hxx:100
#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:95
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:947
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:52
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:992
Type
Definition: file.hxx:670
static RC getSystemPathFromFileURL(const ::rtl::OUString &ustrFileURL,::rtl::OUString &ustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:191
#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:1339
Definition: file.hxx:60
Definition: file.h:121
Definition: file.hxx:96
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:312
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:1419
Definition: file.hxx:64
Definition: file.h:88
Definition: file.h:97
Definition: file.hxx:62
Definition: file.hxx:68
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:94
Definition: file.hxx:85
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1639
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:408
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:826
#define osl_FileStatus_Mask_Attributes
Definition: file.h:367
~Directory()
Destructor.
Definition: file.hxx:1681
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:714
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1713
The directory item class object provides access to file status information.
Definition: file.hxx:1441
Definition: file.hxx:75
#define osl_Volume_Attribute_Removeable
Definition: file.h:538
Definition: file.h:110
bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:518
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:171
void * oslDirectory
Definition: file.h:138
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:553
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:1213
struct _oslVolumeInfo oslVolumeInfo
bool isLink() const
Is it a link?
Definition: file.hxx:770
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:259
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:438
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:474
Definition: file.hxx:59
Definition: file.hxx:76
#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:507
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:686
Definition: file.hxx:87
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
Definition: file.hxx:90
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:350
Definition: file.hxx:99
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1578
Definition: file.hxx:69
Definition: file.h:116
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:781
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:1496
Definition: file.hxx:57
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:1011
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:1693
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:1041
Definition: file.h:122
Definition: file.hxx:104
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1062
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:1881
Definition: file.hxx:63
VolumeDevice()
Constructor.
Definition: file.hxx:340
Base class for observers of directory creation notifications.
Definition: file.hxx:1619
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1674
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:796
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:930
Definition: file.hxx:89
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1475
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:414
Definition: file.h:108
The file class object provides access to file contents and attributes.
Definition: file.hxx:907
bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1599
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:887
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:589
inline::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:871
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:74
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:614
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:811
RC
Definition: file.hxx:56
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:577
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:323
Definition: file.h:89
SAL_DLLPUBLIC oslFileError osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:78
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:67
Definition: file.hxx:103
Definition: file.h:90
Definition: file.hxx:97
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:496
DirectoryItem()
Constructor.
Definition: file.hxx:1450
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:637
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:463
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:1729
#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:1774
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:742
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:244
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1174
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:65
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:1974
Definition: file.hxx:92
Definition: file.hxx:71
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:1243
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath,::rtl::OUString &ustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.hxx:211
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:840
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:1743
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1310
Definition: file.h:346
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:403
#define OSL_PRECOND(c, m)
Definition: diagnose.h:105
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:61
Definition: file.hxx:79
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
Definition: file.hxx:70
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:545
bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:529
Type getFileType() const
Get the file type.
Definition: file.hxx:724
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:1089
inline::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:854
Definition: file.h:117
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1137
Definition: file.hxx:73
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1622
Definition: file.hxx:83
The directory class object provides a enumeration of DirectoryItems.
Definition: file.hxx:1650
void * oslFileHandle
Definition: file.h:634
Definition: file.hxx:86
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:565
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:625
Definition: file.h:91
Definition: file.hxx:88
The VolumeDevice class.
Definition: file.hxx:331
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:1845
Definition: file.h:107
Definition: file.hxx:81
Definition: file.h:99
Definition: file.h:128
Definition: file.hxx:98
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1112
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1278
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
Definition: file.hxx:101
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:695
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:398
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
Definition: file.hxx:82
Definition: file.h:342
Definition: file.h:102
Definition: file.h:340
Definition: file.hxx:102
The FileStatus class.
Definition: file.hxx:653
Definition: file.h:114
Definition: file.hxx:72
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:66
Definition: file.h:95
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:408
Definition: file.h:101
Definition: conditn.hxx:32
Definition: file.h:130
~DirectoryItem()
Destructor.
Definition: file.hxx:1466
Definition: file.h:105
~VolumeDevice()
Destructor.
Definition: file.hxx:360
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:485
Definition: file.hxx:77
#define osl_FileStatus_Mask_FileURL
Definition: file.h:373
~VolumeInfo()
Destructor.
Definition: file.hxx:449
Definition: file.h:134
Definition: file.hxx:80
~File()
Destructor.
Definition: file.hxx:935
Definition: socket_decl.hxx:166
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:131
sal_uInt64 getTotalSpace() const
Determine the total space of a volume device.
Definition: file.hxx:541
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1457
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:84
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:1392
Definition: file.h:106