LibreOffice
LibreOffice 4.2 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 
29 #include <osl/time.h>
30 #include <rtl/ustring.hxx>
31 
32 #include <osl/file.h>
33 #include <rtl/byteseq.hxx>
34 
35 #include <stdio.h>
36 
37 namespace osl
38 {
39 
40 
41 // -----------------------------------------------------------------------------
49 class FileBase
50 {
51 public:
52 
53  enum RC {
99  E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
102  };
103 
104 
105 public:
106 
128  static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
129  {
130  return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
131  }
132 
168  static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
169  {
170  return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
171  }
172 
188  static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
189  {
190  return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
191  }
192 
208  static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
209  {
210  return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
211  }
212 
241  static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
242  {
243  return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
244  }
245 
256  static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
257  {
258  return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
259  }
260 
309  static inline RC createTempFile(
310  ::rtl::OUString* pustrDirectoryURL,
311  oslFileHandle* pHandle,
312  ::rtl::OUString* pustrTempFileURL)
313  {
314  rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
315  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
316 
317  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
318  }
319 };
320 
321 
322 // -----------------------------------------------------------------------------
328 class VolumeDevice : public FileBase
329 {
330  oslVolumeDeviceHandle _aHandle;
331 
332 public:
333 
337  VolumeDevice() : _aHandle( NULL )
338  {
339  }
340 
347  VolumeDevice( const VolumeDevice & rDevice )
348  {
349  _aHandle = rDevice._aHandle;
350  if ( _aHandle )
351  osl_acquireVolumeDeviceHandle( _aHandle );
352  }
353 
358  {
359  if ( _aHandle )
360  osl_releaseVolumeDeviceHandle( _aHandle );
361  }
362 
369  inline VolumeDevice & operator =( const VolumeDevice & rDevice )
370  {
371  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
372 
373  if ( newHandle )
374  osl_acquireVolumeDeviceHandle( newHandle );
375 
376  if ( _aHandle )
377  osl_releaseVolumeDeviceHandle( _aHandle );
378 
379  _aHandle = newHandle;
380 
381  return *this;
382  }
383 
390  {
391  rtl::OUString aPath;
392  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
393  return aPath;
394  }
395 
396  friend class VolumeInfo;
397 };
398 
399 // -----------------------------------------------------------------------------
400 
401 class Directory;
402 
412 {
413  oslVolumeInfo _aInfo;
414  sal_uInt32 _nMask;
415  VolumeDevice _aDevice;
416 
421 
425  VolumeInfo& operator = ( VolumeInfo& );
426 
427 public:
428 
435  VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
436  {
437  _aInfo.uStructSize = sizeof( oslVolumeInfo );
438  memset( &_aInfo.uValidFields, 0, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ) );
439  _aInfo.pDeviceHandle = &_aDevice._aHandle;
440  }
441 
446  {
447  if( _aInfo.ustrFileSystemName )
449  }
450 
459  inline sal_Bool isValid( sal_uInt32 nMask ) const
460  {
461  return ( nMask & _aInfo.uValidFields ) == nMask;
462  }
463 
470  inline sal_Bool getRemoteFlag() const
471  {
472  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
473  }
474 
482  {
483  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
484  }
485 
493  {
494  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
495  }
496 
504  {
505  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
506  }
507 
514  inline sal_Bool getFixedDiskFlag() const
515  {
516  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
517  }
518 
525  inline sal_Bool getRAMDiskFlag() const
526  {
527  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
528  }
529 
537  inline sal_uInt64 getTotalSpace() const
538  {
539  return _aInfo.uTotalSpace;
540  }
541 
549  inline sal_uInt64 getFreeSpace() const
550  {
551  return _aInfo.uFreeSpace;
552  }
553 
561  inline sal_uInt64 getUsedSpace() const
562  {
563  return _aInfo.uUsedSpace;
564  }
565 
573  inline sal_uInt32 getMaxNameLength() const
574  {
575  return _aInfo.uMaxNameLength;
576  }
577 
585  inline sal_uInt32 getMaxPathLength() const
586  {
587  return _aInfo.uMaxPathLength;
588  }
589 
597  inline ::rtl::OUString getFileSystemName() const
598  {
600  }
601 
602 
611  {
612  return _aDevice;
613  }
614 
622  {
624  }
625 
634  {
636  }
637 
638  friend class Directory;
639 };
640 
641 // -----------------------------------------------------------------------------
642 class DirectoryItem;
643 
650 {
651  oslFileStatus _aStatus;
652  sal_uInt32 _nMask;
653 
658 
662  FileStatus& operator = ( FileStatus& );
663 
664 public:
665 
666  enum Type {
675  };
676 
683  FileStatus( sal_uInt32 nMask ): _nMask( nMask )
684  {
685  _aStatus.uStructSize = sizeof( oslFileStatus );
686  memset( &_aStatus.uValidFields, 0, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ) );
687  }
688 
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 sal_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 sal_Bool isDirectory() const
740  {
741  return ( getFileType() == Directory || getFileType() == Volume );
742  }
743 
754  inline sal_Bool isRegular() const
755  {
756  return ( getFileType() == Regular );
757  }
758 
767  inline sal_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 
897 // -----------------------------------------------------------------------------
904 class File: public FileBase
905 {
906  oslFileHandle _pData;
907  ::rtl::OUString _aPath;
908 
912  File( File& );
913 
917  File& operator = ( File& );
918 
919 public:
920 
927  File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
928 
932  inline ~File()
933  {
934  close();
935  }
936 
944  inline rtl::OUString getURL() const { return _aPath; }
945 
989  inline RC open( sal_uInt32 uFlags )
990  {
991  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
992  }
993 
1008  inline RC close()
1009  {
1010  oslFileError Error = osl_File_E_BADF;
1011 
1012  if( _pData )
1013  {
1014  Error=osl_closeFile( _pData );
1015  _pData = NULL;
1016  }
1017 
1018  return static_cast< RC >( Error );
1019  }
1020 
1038  inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1039  {
1040  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1041  }
1042 
1059  inline RC getPos( sal_uInt64& uPos )
1060  {
1061  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1062  }
1063 
1086  inline RC isEndOfFile( sal_Bool *pIsEOF )
1087  {
1088  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1089  }
1090 
1109  inline RC setSize( sal_uInt64 uSize )
1110  {
1111  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1112  }
1113 
1134  inline RC getSize( sal_uInt64 &rSize )
1135  {
1136  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1137  }
1138 
1171  inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1172  {
1173  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1174  }
1175 
1210  inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1211  {
1212  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1213  }
1214 
1215 
1240  inline RC readLine( ::rtl::ByteSequence& aSeq )
1241  {
1242  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1243  }
1244 
1275  inline RC sync() const
1276  {
1277  OSL_PRECOND(_pData, "File::sync(): File not open");
1278  return static_cast< RC >(osl_syncFile(_pData));
1279  }
1280 
1307  inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1308  {
1309  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1310  }
1311 
1336  inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1337  {
1338  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1339  }
1340 
1369  inline static RC remove( const ::rtl::OUString& ustrFileURL )
1370  {
1371  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1372  }
1373 
1389  inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1390  {
1391  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1392  }
1393 
1416  inline static RC setTime(
1417  const ::rtl::OUString& ustrFileURL,
1418  const TimeValue& rCreationTime,
1419  const TimeValue& rLastAccessTime,
1420  const TimeValue& rLastWriteTime )
1421  {
1422  return static_cast< RC >( osl_setFileTime(
1423  ustrFileURL.pData,
1424  &rCreationTime,
1425  &rLastAccessTime,
1426  &rLastWriteTime ) );
1427  }
1428 
1429  friend class DirectoryItem;
1430 };
1431 
1432 // -----------------------------------------------------------------------------
1439 {
1440  oslDirectoryItem _pData;
1441 
1442 public:
1443 
1447  DirectoryItem(): _pData( NULL )
1448  {
1449  }
1450 
1454  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1455  {
1456  if( _pData )
1457  osl_acquireDirectoryItem( _pData );
1458  }
1459 
1464  {
1465  if( _pData )
1466  osl_releaseDirectoryItem( _pData );
1467  }
1468 
1473  {
1474  if (&rItem != this)
1475  {
1476  if( _pData )
1477  osl_releaseDirectoryItem( _pData );
1478 
1479  _pData = rItem._pData;
1480 
1481  if( _pData )
1482  osl_acquireDirectoryItem( _pData );
1483  }
1484  return *this;
1485  }
1486 
1493  inline sal_Bool is()
1494  {
1495  return _pData != NULL;
1496  }
1497 
1532  static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1533  {
1534  if( rItem._pData)
1535  {
1536  osl_releaseDirectoryItem( rItem._pData );
1537  rItem._pData = NULL;
1538  }
1539 
1540  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1541  }
1542 
1575  inline RC getFileStatus( FileStatus& rStatus )
1576  {
1577  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1578  }
1579 
1596  inline sal_Bool isIdenticalTo( const DirectoryItem &pOther )
1597  {
1598  return osl_identicalDirectoryItem( _pData, pOther._pData );
1599  }
1600 
1601  friend class Directory;
1602 };
1603 
1604 //###########################################
1605 
1617 {
1618 public:
1620 
1630  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1631 };
1632 
1633 //###########################################
1634 // This just an internal helper function for
1635 // private use.
1636 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1637 {
1638  (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1639 }
1640 
1647 class Directory: public FileBase
1648 {
1649  oslDirectory _pData;
1650  ::rtl::OUString _aPath;
1651 
1655  Directory( Directory& );
1656 
1660  Directory& operator = ( Directory& );
1661 
1662 public:
1663 
1671  Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
1672  {
1673  }
1674 
1679  {
1680  close();
1681  }
1682 
1690  inline rtl::OUString getURL() const { return _aPath; }
1691 
1710  inline RC open()
1711  {
1712  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1713  }
1714 
1726  inline sal_Bool isOpen() { return _pData != NULL; }
1727 
1740  inline RC close()
1741  {
1742  oslFileError Error = osl_File_E_BADF;
1743 
1744  if( _pData )
1745  {
1746  Error=osl_closeDirectory( _pData );
1747  _pData = NULL;
1748  }
1749 
1750  return static_cast< RC >( Error );
1751  }
1752 
1753 
1771  inline RC reset()
1772  {
1773  close();
1774  return open();
1775  }
1776 
1800  inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1801  {
1802  if( rItem._pData )
1803  {
1804  osl_releaseDirectoryItem( rItem._pData );
1805  rItem._pData = 0;
1806  }
1807  return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1808  }
1809 
1810 
1842  inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1843  {
1844  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1845  }
1846 
1874  inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
1875  {
1876  return static_cast< RC >( osl_createDirectory( ustrDirectoryURL.pData ) );
1877  }
1878 
1907  inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1908  {
1909  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1910  }
1911 
1964  static RC createPath(
1965  const ::rtl::OUString& aDirectoryUrl,
1966  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1967  {
1968  return static_cast< RC >(osl_createDirectoryPath(
1969  aDirectoryUrl.pData,
1970  (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1971  aDirectoryCreationObserver));
1972  }
1973 };
1974 
1975 } /* namespace osl */
1976 
1977 #endif // INCLUDED_OSL_FILE_HXX
1978 
1979 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void * oslDirectoryItem
Definition: file.h:139
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:435
inline::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:868
static RC getSystemPathFromFileURL(const ::rtl::OUString &ustrFileURL,::rtl::OUString &ustrSystemPath)
Convert a file URL into a system dependend path.
Definition: file.hxx:188
SAL_DLLPUBLIC oslFileError osl_openFile(rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags)
Open a regular file.
Definition: file.h:116
SAL_DLLPUBLIC oslFileError osl_getFileStatus(oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
Retrieve information about a single file or directory.
RC close()
Close a directory.
Definition: file.hxx:1740
Definition: file.hxx:74
SAL_DLLPUBLIC oslFileError osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.h:117
Definition: file.hxx:100
Definition: file.h:90
sal_uInt64 uTotalSpace
Total availiable space on the volume for the current process/user.
Definition: file.h:576
RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
Write a number of bytes to a file.
Definition: file.hxx:1210
Definition: file.hxx:83
Definition: file.h:125
Definition: file.h:123
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:309
sal_Bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:711
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependend path.
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:572
Definition: file.hxx:60
static RC create(const ::rtl::OUString &ustrDirectoryURL)
Create a directory.
Definition: file.hxx:1874
Definition: file.h:126
Base class for all File System specific objects.
Definition: file.hxx:49
Definition: file.h:100
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_DLLPUBLIC oslFileError osl_releaseVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Release a volume device handle.
Definition: file.h:131
~DirectoryItem()
Destructor.
Definition: file.hxx:1463
Definition: file.hxx:81
SAL_DLLPUBLIC oslFileError osl_getCanonicalName(rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL)
Determine a valid unused canonical name for a requested name.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:82
SAL_DLLPUBLIC oslFileError osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
Test if the end of a file is reached.
sal_Bool isRegular() const
Is it a regular file?
Definition: file.hxx:754
static RC createPath(const ::rtl::OUString &aDirectoryUrl, DirectoryCreationObserver *aDirectoryCreationObserver=NULL)
Create a directory path.
Definition: file.hxx:1964
Definition: file.h:113
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:389
Definition: file.h:103
sal_uInt32 uMaxNameLength
Maximum length of file name of a single item.
Definition: file.h:582
FileStatus(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:683
Definition: file.h:92
Definition: file.hxx:86
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1307
Definition: file.hxx:55
struct _oslVolumeInfo oslVolumeInfo
Definition: file.hxx:95
SAL_DLLPUBLIC oslFileError osl_releaseDirectoryItem(oslDirectoryItem Item)
Decrease the refcount of a directory item handle.
Definition: file.h:108
static RC getTempDirURL(::rtl::OUString &ustrTempDirURL)
Retrieves the file URL of the system's temporary directory path.
Definition: file.hxx:256
SAL_DLLPUBLIC oslFileError osl_setFileAttributes(rtl_uString *pustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:668
Definition: file.h:340
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1171
~Directory()
Destructor.
Definition: file.hxx:1678
Definition: file.h:96
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
Definition: time.h:42
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:1690
#define osl_Volume_Attribute_Remote
Definition: file.h:539
C++ class representing a SAL byte sequence.
Definition: byteseq.h:161
Definition: file.hxx:63
sal_uInt64 getUsedSpace() const
Determine the used space of a volume device.
Definition: file.hxx:561
Definition: file.hxx:58
Definition: socket_decl.hxx:162
RC setPos(sal_uInt32 uHow, sal_Int64 uPos) SAL_WARN_UNUSED_RESULT
Set the internal position pointer of an open file.
Definition: file.hxx:1038
static RC getVolumeInfo(const ::rtl::OUString &ustrDirectoryURL, VolumeInfo &rInfo)
Retrieve information about a volume.
Definition: file.hxx:1842
Definition: file.hxx:76
static RC setAttributes(const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:1389
#define osl_Volume_Attribute_Case_Sensitive
Definition: file.h:546
The directory class object provides a enumeration of DirectoryItems.
Definition: file.hxx:1647
Type getFileType() const
Get the file type.
Definition: file.hxx:721
Definition: file.hxx:67
#define OSL_PRECOND(c, m)
Definition: diagnose.h:159
Main goals and usage hints.
#define osl_Volume_Attribute_FloppyDisk
Definition: file.h:543
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1134
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1619
Definition: file.hxx:87
RC readLine(::rtl::ByteSequence &aSeq)
Read a line from a file.
Definition: file.hxx:1240
inline::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:851
rtl_uString * ustrFileSystemName
Points to a string that receives the name of the file system type.
Definition: file.h:587
Definition: file.hxx:96
sal_Bool isOpen()
Query if directory is open.
Definition: file.hxx:1726
Definition: file.hxx:66
Definition: file.h:93
#define osl_FileStatus_Mask_ModifyTime
Definition: file.h:370
Definition: file.hxx:93
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:808
SAL_DLLPUBLIC oslFileError osl_acquireVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Acquire a volume device handle.
RC
Definition: file.hxx:53
SAL_DLLPUBLIC oslFileError osl_acquireDirectoryItem(oslDirectoryItem Item)
Increase the refcount of a directory item handle.
SAL_DLLPUBLIC oslFileError osl_readLine(oslFileHandle Handle, sal_Sequence **ppSequence)
Read a line from a file.
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:793
SAL_DLLPUBLIC oslFileError osl_syncFile(oslFileHandle Handle)
Synchronize the memory representation of a file with that on the physical medium. ...
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:545
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.hxx:91
Definition: file.hxx:80
Definition: file.hxx:670
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:347
sal_Bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:459
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1275
RC open(sal_uInt32 uFlags)
Open a regular file.
Definition: file.hxx:989
#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
Type
Definition: file.hxx:666
Definition: file.h:107
Definition: file.h:99
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:1336
sal_Bool is()
Check for validity of this instance.
Definition: file.hxx:1493
Definition: file.h:91
SAL_DLLPUBLIC oslFileError osl_getVolumeDeviceMountPath(oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL)
Get the full qualified URL where a device is mounted to.
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:168
void * oslDirectory
Definition: file.h:138
Definition: file.hxx:674
Definition: file.h:128
sal_Bool getFloppyDiskFlag() const
Check the floppy disc flag.
Definition: file.hxx:503
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:391
sal_Bool isDirectory() const
Is it a directory? This method returns True for both directories, and volumes.
Definition: file.hxx:739
Definition: file.h:342
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:241
Structure containing information about files and directories.
Definition: file.h:387
DirectoryItem()
Constructor.
Definition: file.hxx:1447
Definition: file.hxx:92
Definition: file.h:95
sal_Bool getCompactDiscFlag() const
Check the compact disc flag.
Definition: file.hxx:492
Definition: file.hxx:73
sal_uInt64 uAttributes
File attributes.
Definition: file.h:395
Definition: file.h:115
rtl_uString * ustrFileURL
Full URL of the file.
Definition: file.h:411
Definition: file.h:114
sal_uInt64 uFileSize
Size in bytes of the file.
Definition: file.h:405
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:837
Definition: file.hxx:669
SAL_DLLPUBLIC oslFileError osl_getVolumeInformation(rtl_uString *pustrDirectoryURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask)
Retrieve information about a volume.
~File()
Destructor.
Definition: file.hxx:932
Definition: file.h:101
Definition: file.hxx:70
SAL_DLLPUBLIC oslFileError osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.h:134
Definition: file.hxx:94
Definition: file.h:105
bool isCasePreservingFileSystem() const
Return whether the file system preserves the case of file and directory names or not.
Definition: file.hxx:633
SAL_DLLPUBLIC oslFileError osl_openDirectory(rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory)
Open a directory for enumerating its contents.
Definition: file.h:120
Definition: file.h:88
inline::rtl::OUString getFileSystemName() const
Determine the name of the volume device's File System.
Definition: file.hxx:597
Definition: file.h:341
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.
SAL_DLLPUBLIC oslFileError osl_searchFileURL(rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL)
Searche a full qualified system path or a file URL.
Definition: file.h:347
bool isCaseSensitiveFileSystem() const
Return whether the file system is case sensitive or case insensitive.
Definition: file.hxx:621
Definition: file.hxx:78
void * oslVolumeDeviceHandle
Definition: file.h:462
sal_uInt32 uMaxPathLength
Maximum length of a full quallified path in system notation.
Definition: file.h:584
Definition: file.hxx:72
oslVolumeDeviceHandle * pDeviceHandle
Pointer to handle the receives underlying device.
Definition: file.h:589
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath,::rtl::OUString &ustrFileURL)
Convert a system dependend path into a file URL.
Definition: file.hxx:208
Definition: file.hxx:65
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1575
Definition: file.hxx:85
TimeValue aAccessTime
Last access time in nanoseconds since 1/1/1970.
Definition: file.h:401
The VolumeInfo class.
Definition: file.hxx:411
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
Definition: file.h:104
Definition: file.h:344
Definition: file.hxx:88
Definition: file.h:112
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:944
Definition: file.hxx:68
Definition: file.hxx:97
Definition: file.hxx:98
RC isEndOfFile(sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:1086
#define osl_Volume_Attribute_RAMDisk
Definition: file.h:542
SAL_DLLPUBLIC oslFileError osl_removeDirectory(rtl_uString *pustrDirectoryURL)
Remove an empty directory.
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:374
Definition: file.h:94
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1059
Definition: file.h:133
VolumeDevice & operator=(const VolumeDevice &rDevice)
Assignment operator.
Definition: file.hxx:369
Definition: file.h:111
sal_uInt32 uAttributes
Attributes of the volume (remote and/or removable)
Definition: file.h:574
Definition: file.h:102
Definition: file.h:127
oslFileType eType
The type of the file (file, directory, volume).
Definition: file.h:393
Definition: file.h:132
#define osl_Volume_Attribute_CompactDisc
Definition: file.h:540
sal_uInt64 uFreeSpace
Free space on the volume for the current process/user.
Definition: file.h:580
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1472
static RC setTime(const ::rtl::OUString &ustrFileURL, const TimeValue &rCreationTime, const TimeValue &rLastAccessTime, const TimeValue &rLastWriteTime)
Set the file time.
Definition: file.hxx:1416
sal_Bool getRemoteFlag() const
Check the remote flag.
Definition: file.hxx:470
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
Definition: file.h:130
Definition: file.hxx:64
The directory item class object provides access to file status information.
Definition: file.hxx:1438
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1636
Definition: file.h:97
Definition: file.hxx:57
Definition: file.hxx:59
~VolumeInfo()
Destructor.
Definition: file.hxx:445
SAL_DLLPUBLIC sal_Bool osl_identicalDirectoryItem(oslDirectoryItem pItemA, oslDirectoryItem pItemB)
Determine if two directory items point the same underlying file.
sal_Bool isLink() const
Is it a link?
Definition: file.hxx:767
VolumeDevice()
Constructor.
Definition: file.hxx:337
Definition: file.h:122
#define osl_FileStatus_Mask_AccessTime
Definition: file.h:369
void * oslFileHandle
Definition: file.h:634
RC reset()
Resets the directory item enumeration to the beginning.
Definition: file.hxx:1771
~FileStatus()
Destructor.
Definition: file.hxx:692
SAL_DLLPUBLIC oslFileError osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize)
Get the file size of an open file.
SAL_DLLPUBLIC oslFileError osl_getFileURLFromSystemPath(rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL)
Convert a system dependend path into a file URL.
Definition: file.h:118
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1671
#define osl_FileStatus_Mask_FileSize
Definition: file.h:371
static RC getCanonicalName(const ::rtl::OUString &ustrRequestedURL,::rtl::OUString &ustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.hxx:128
sal_Bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:514
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:823
The VolumeDevice class.
Definition: file.hxx:328
Definition: file.h:106
oslFileError
Definition: file.h:86
Definition: file.h:98
Definition: file.h:124
#define osl_FileStatus_Mask_Attributes
Definition: file.h:367
#define osl_FileStatus_Mask_FileName
Definition: file.h:372
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1800
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:403
unsigned char sal_Bool
Definition: types.h:46
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
#define osl_Volume_Attribute_Removeable
Definition: file.h:538
Definition: file.h:119
Definition: file.hxx:90
sal_Bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:525
Definition: file.hxx:56
sal_uInt64 uUsedSpace
Used space on the volume for the current process/user.
Definition: file.h:578
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
~VolumeDevice()
Destructor.
Definition: file.hxx:357
Definition: file.hxx:99
Definition: file.hxx:71
sal_Bool getRemoveableFlag() const
Check the removeable flag.
Definition: file.hxx:481
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:778
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...
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1454
Definition: file.h:89
rtl_uString * ustrLinkTargetURL
Full URL of the target file if the file itself is a link.
Definition: file.h:415
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:398
Definition: file.hxx:54
Definition: file.h:87
SAL_DLLPUBLIC oslFileError osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
Retrieve the next item of a previously opened directory.
inline::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:884
struct _oslFileStatus oslFileStatus
Definition: file.h:345
Definition: file.h:121
Base class for observers of directory creation notifications.
Definition: file.hxx:1616
#define osl_FileStatus_Mask_FileURL
Definition: file.h:373
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:408
Definition: file.hxx:82
Definition: file.hxx:75
Definition: file.h:109
Definition: file.hxx:101
The FileStatus class.
Definition: file.hxx:649
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:585
sal_Bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1596
SAL_DLLPUBLIC oslFileError osl_readFile(oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead)
Read a number of bytes from a file.
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:570
Definition: file.hxx:77
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:305
Definition: file.hxx:61
Definition: file.hxx:673
The file class object provides access to file contents and attributes.
Definition: file.hxx:904
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:927
SAL_DLLPUBLIC oslFileError osl_moveFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Move a file or directory to a new destination or renames it.
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:549
SAL_DLLPUBLIC oslFileError osl_writeFile(oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten)
Write a number of bytes to a file.
RC close()
Close an open file.
Definition: file.hxx:1008
SAL_DLLPUBLIC oslFileError osl_getTempDirURL(rtl_uString **pustrTempDirURL)
Retrieves the file URL of the system's temporary directory path.
SAL_DLLPUBLIC oslFileError osl_copyFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Copy a file to a new destination.
SAL_DLLPUBLIC oslFileError osl_createDirectory(rtl_uString *pustrDirectoryURL)
Create a directory.
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:573
sal_uInt64 getTotalSpace() const
Determine the total space of a volume device.
Definition: file.hxx:537
Definition: file.h:110
#define osl_Volume_Attribute_FixedDisk
Definition: file.h:541
SAL_DLLPUBLIC oslFileError osl_getDirectoryItem(rtl_uString *pustrFileURL, oslDirectoryItem *pItem)
Retrieve a single directory item.
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1710
#define osl_FileStatus_Mask_CreationTime
Definition: file.h:368
Definition: file.h:343
Definition: file.hxx:62
Definition: file.hxx:79
Definition: file.h:129
Definition: file.hxx:89
Definition: file.hxx:69
Definition: file.h:346
#define osl_FileStatus_Mask_Type
Definition: file.h:366
SAL_DLLPUBLIC oslFileError osl_setFileTime(rtl_uString *pustrFileURL, const TimeValue *aCreationTime, const TimeValue *aLastAccessTime, const TimeValue *aLastWriteTime)
Set the file time.
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:389
Structure containing information about volumes.
Definition: file.h:568
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1109
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:610
Definition: file.hxx:672
Definition: file.hxx:84