LibreOffice
LibreOffice 5.0 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 <sal/log.hxx>
30 #include <osl/time.h>
31 #include <rtl/ustring.hxx>
32 
33 #include <osl/file.h>
34 #include <osl/diagnose.h>
35 #include <rtl/byteseq.hxx>
36 
37 #include <stdio.h>
38 
39 namespace osl
40 {
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 : 0;
317  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
318 
319  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
320  }
321 };
322 
323 
324 
330 class VolumeDevice : public FileBase
331 {
332  oslVolumeDeviceHandle _aHandle;
333 
334 public:
335 
339  VolumeDevice() : _aHandle( NULL )
340  {
341  }
342 
349  VolumeDevice( const VolumeDevice & rDevice )
350  {
351  _aHandle = rDevice._aHandle;
352  if ( _aHandle )
353  osl_acquireVolumeDeviceHandle( _aHandle );
354  }
355 
360  {
361  if ( _aHandle )
362  osl_releaseVolumeDeviceHandle( _aHandle );
363  }
364 
371  inline VolumeDevice & operator =( const VolumeDevice & rDevice )
372  {
373  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
374 
375  if ( newHandle )
376  osl_acquireVolumeDeviceHandle( newHandle );
377 
378  if ( _aHandle )
379  osl_releaseVolumeDeviceHandle( _aHandle );
380 
381  _aHandle = newHandle;
382 
383  return *this;
384  }
385 
392  {
393  rtl::OUString aPath;
394  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
395  return aPath;
396  }
397 
398  friend class VolumeInfo;
399 };
400 
401 
402 
403 class Directory;
404 
414 {
415  oslVolumeInfo _aInfo;
416  sal_uInt32 _nMask;
417  VolumeDevice _aDevice;
418 
423 
427  VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
428 
429 public:
430 
437  VolumeInfo( sal_uInt32 nMask )
438  : _nMask( nMask )
439  {
440  memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
441  _aInfo.uStructSize = sizeof( oslVolumeInfo );
442  _aInfo.pDeviceHandle = &_aDevice._aHandle;
443  }
444 
449  {
450  if( _aInfo.ustrFileSystemName )
452  }
453 
462  inline bool isValid( sal_uInt32 nMask ) const
463  {
464  return ( nMask & _aInfo.uValidFields ) == nMask;
465  }
466 
473  inline bool getRemoteFlag() const
474  {
475  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
476  }
477 
484  inline bool getRemoveableFlag() const
485  {
486  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
487  }
488 
495  inline bool getCompactDiscFlag() const
496  {
497  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
498  }
499 
506  inline bool getFloppyDiskFlag() const
507  {
508  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
509  }
510 
517  inline bool getFixedDiskFlag() const
518  {
519  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
520  }
521 
528  inline bool getRAMDiskFlag() const
529  {
530  return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
531  }
532 
540  inline sal_uInt64 getTotalSpace() const
541  {
542  return _aInfo.uTotalSpace;
543  }
544 
552  inline sal_uInt64 getFreeSpace() const
553  {
554  return _aInfo.uFreeSpace;
555  }
556 
564  inline sal_uInt64 getUsedSpace() const
565  {
566  return _aInfo.uUsedSpace;
567  }
568 
576  inline sal_uInt32 getMaxNameLength() const
577  {
578  return _aInfo.uMaxNameLength;
579  }
580 
588  inline sal_uInt32 getMaxPathLength() const
589  {
590  return _aInfo.uMaxPathLength;
591  }
592 
600  inline ::rtl::OUString getFileSystemName() const
601  {
603  }
604 
605 
614  {
615  return _aDevice;
616  }
617 
625  {
626  return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
627  }
628 
637  {
639  }
640 
641  friend class Directory;
642 };
643 
644 
645 class DirectoryItem;
646 
653 {
654  oslFileStatus _aStatus;
655  sal_uInt32 _nMask;
656 
661 
665  FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
666 
667 public:
668 
669  enum Type {
678  };
679 
685  FileStatus(sal_uInt32 nMask)
686  : _nMask(nMask)
687  {
688  memset(&_aStatus, 0, sizeof(_aStatus));
689  _aStatus.uStructSize = sizeof(_aStatus);
690  }
691 
695  {
696  if ( _aStatus.ustrFileURL )
697  rtl_uString_release( _aStatus.ustrFileURL );
698  if ( _aStatus.ustrLinkTargetURL )
700  if ( _aStatus.ustrFileName )
701  rtl_uString_release( _aStatus.ustrFileName );
702  }
703 
713  inline bool isValid( sal_uInt32 nMask ) const
714  {
715  return ( nMask & _aStatus.uValidFields ) == nMask;
716  }
717 
723  inline Type getFileType() const
724  {
725  SAL_INFO_IF(
726  !isValid(osl_FileStatus_Mask_Type), "sal.osl",
727  "no FileStatus Type determined");
729  ? static_cast< Type >(_aStatus.eType) : Unknown;
730  }
731 
741  inline bool isDirectory() const
742  {
743  return ( getFileType() == Directory || getFileType() == Volume );
744  }
745 
756  inline bool isRegular() const
757  {
758  return ( getFileType() == Regular );
759  }
760 
769  inline bool isLink() const
770  {
771  return ( getFileType() == Link );
772  }
773 
780  inline sal_uInt64 getAttributes() const
781  {
782  SAL_INFO_IF(
784  "no FileStatus Attributes determined");
785  return _aStatus.uAttributes;
786  }
787 
795  inline TimeValue getCreationTime() const
796  {
797  SAL_INFO_IF(
799  "no FileStatus CreationTime determined");
800  return _aStatus.aCreationTime;
801  }
802 
810  inline TimeValue getAccessTime() const
811  {
812  SAL_INFO_IF(
814  "no FileStatus AccessTime determined");
815  return _aStatus.aAccessTime;
816  }
817 
825  inline TimeValue getModifyTime() const
826  {
827  SAL_INFO_IF(
829  "no FileStatus ModifyTime determined");
830  return _aStatus.aModifyTime;
831  }
832 
839  inline sal_uInt64 getFileSize() const
840  {
841  SAL_INFO_IF(
843  "no FileStatus FileSize determined");
844  return _aStatus.uFileSize;
845  }
846 
853  inline ::rtl::OUString getFileName() const
854  {
855  SAL_INFO_IF(
857  "no FileStatus FileName determined");
859  ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
860  }
861 
862 
870  inline ::rtl::OUString getFileURL() const
871  {
872  SAL_INFO_IF(
874  "no FileStatus FileURL determined");
876  ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
877  }
878 
886  inline ::rtl::OUString getLinkTargetURL() const
887  {
888  SAL_INFO_IF(
890  "no FileStatus LinkTargetURL determined");
893  }
894 
895  friend class DirectoryItem;
896 };
897 
898 
899 
906 class File: public FileBase
907 {
908  oslFileHandle _pData;
909  ::rtl::OUString _aPath;
910 
915 
919  File& operator = ( File& ) SAL_DELETED_FUNCTION;
920 
921 public:
922 
929  File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
930 
934  inline ~File()
935  {
936  close();
937  }
938 
946  inline rtl::OUString getURL() const { return _aPath; }
947 
991  inline RC open( sal_uInt32 uFlags )
992  {
993  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
994  }
995 
1010  inline RC close()
1011  {
1012  oslFileError Error = osl_File_E_BADF;
1013 
1014  if( _pData )
1015  {
1016  Error=osl_closeFile( _pData );
1017  _pData = NULL;
1018  }
1019 
1020  return static_cast< RC >( Error );
1021  }
1022 
1040  inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1041  {
1042  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1043  }
1044 
1061  inline RC getPos( sal_uInt64& uPos )
1062  {
1063  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1064  }
1065 
1088  inline RC isEndOfFile( sal_Bool *pIsEOF )
1089  {
1090  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1091  }
1092 
1111  inline RC setSize( sal_uInt64 uSize )
1112  {
1113  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1114  }
1115 
1136  inline RC getSize( sal_uInt64 &rSize )
1137  {
1138  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1139  }
1140 
1173  inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1174  {
1175  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1176  }
1177 
1212  inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1213  {
1214  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1215  }
1216 
1217 
1242  inline RC readLine( ::rtl::ByteSequence& aSeq )
1243  {
1244  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1245  }
1246 
1277  inline RC sync() const
1278  {
1279  OSL_PRECOND(_pData, "File::sync(): File not open");
1280  return static_cast< RC >(osl_syncFile(_pData));
1281  }
1282 
1309  inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1310  {
1311  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1312  }
1313 
1338  inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1339  {
1340  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1341  }
1342 
1371  inline static RC remove( const ::rtl::OUString& ustrFileURL )
1372  {
1373  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1374  }
1375 
1391  inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1392  {
1393  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1394  }
1395 
1418  inline static RC setTime(
1419  const ::rtl::OUString& ustrFileURL,
1420  const TimeValue& rCreationTime,
1421  const TimeValue& rLastAccessTime,
1422  const TimeValue& rLastWriteTime )
1423  {
1424  return static_cast< RC >( osl_setFileTime(
1425  ustrFileURL.pData,
1426  &rCreationTime,
1427  &rLastAccessTime,
1428  &rLastWriteTime ) );
1429  }
1430 
1431  friend class DirectoryItem;
1432 };
1433 
1434 
1441 {
1442  oslDirectoryItem _pData;
1443 
1444 public:
1445 
1449  DirectoryItem(): _pData( NULL )
1450  {
1451  }
1452 
1456  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1457  {
1458  if( _pData )
1459  osl_acquireDirectoryItem( _pData );
1460  }
1461 
1466  {
1467  if( _pData )
1468  osl_releaseDirectoryItem( _pData );
1469  }
1470 
1475  {
1476  if (&rItem != this)
1477  {
1478  if( _pData )
1479  osl_releaseDirectoryItem( _pData );
1480 
1481  _pData = rItem._pData;
1482 
1483  if( _pData )
1484  osl_acquireDirectoryItem( _pData );
1485  }
1486  return *this;
1487  }
1488 
1495  inline bool is()
1496  {
1497  return _pData != NULL;
1498  }
1499 
1534  static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1535  {
1536  if( rItem._pData)
1537  {
1538  osl_releaseDirectoryItem( rItem._pData );
1539  rItem._pData = NULL;
1540  }
1541 
1542  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1543  }
1544 
1577  inline RC getFileStatus( FileStatus& rStatus )
1578  {
1579  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1580  }
1581 
1598  inline bool isIdenticalTo( const DirectoryItem &pOther )
1599  {
1600  return osl_identicalDirectoryItem( _pData, pOther._pData );
1601  }
1602 
1603  friend class Directory;
1604 };
1605 
1606 
1607 
1619 {
1620 public:
1622 
1632  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1633 };
1634 
1635 
1636 // This just an internal helper function for
1637 // private use.
1638 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1639 {
1640  (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
1641 }
1642 
1649 class Directory: public FileBase
1650 {
1651  oslDirectory _pData;
1652  ::rtl::OUString _aPath;
1653 
1658 
1662  Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1663 
1664 public:
1665 
1673  Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
1674  {
1675  }
1676 
1681  {
1682  close();
1683  }
1684 
1692  inline rtl::OUString getURL() const { return _aPath; }
1693 
1712  inline RC open()
1713  {
1714  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1715  }
1716 
1728  inline bool isOpen() { return _pData != NULL; }
1729 
1742  inline RC close()
1743  {
1744  oslFileError Error = osl_File_E_BADF;
1745 
1746  if( _pData )
1747  {
1748  Error=osl_closeDirectory( _pData );
1749  _pData = NULL;
1750  }
1751 
1752  return static_cast< RC >( Error );
1753  }
1754 
1755 
1773  inline RC reset()
1774  {
1775  close();
1776  return open();
1777  }
1778 
1802  inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1803  {
1804  if( rItem._pData )
1805  {
1806  osl_releaseDirectoryItem( rItem._pData );
1807  rItem._pData = 0;
1808  }
1809  return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1810  }
1811 
1812 
1844  inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1845  {
1846  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1847  }
1848 
1880  inline static RC create(
1881  const ::rtl::OUString& ustrDirectoryURL,
1882  sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1883  {
1884  return static_cast< RC >(
1885  osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1886  }
1887 
1916  inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1917  {
1918  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1919  }
1920 
1973  static RC createPath(
1974  const ::rtl::OUString& aDirectoryUrl,
1975  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1976  {
1977  return static_cast< RC >(osl_createDirectoryPath(
1978  aDirectoryUrl.pData,
1979  (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1980  aDirectoryCreationObserver));
1981  }
1982 };
1983 
1984 } /* namespace osl */
1985 
1986 #endif // INCLUDED_OSL_FILE_HXX
1987 
1988 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: file.hxx:82
Definition: file.hxx:58
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1474
Definition: file.hxx:85
#define osl_File_OpenFlag_Read
Definition: file.h:638
Definition: file.h:129
SAL_DLLPUBLIC oslFileError osl_syncFile(oslFileHandle Handle)
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.h:127
bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1598
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.
bool getRemoteFlag() const
Check the remote flag.
Definition: file.hxx:473
sal_uInt64 uTotalSpace
Total available space on the volume for the current process/user.
Definition: file.h:576
#define osl_Volume_Attribute_Case_Sensitive
Definition: file.h:546
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
bool getFloppyDiskFlag() const
Check the floppy disc flag.
Definition: file.hxx:506
#define osl_Volume_Attribute_RAMDisk
Definition: file.h:542
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:572
#define osl_Volume_Attribute_FloppyDisk
Definition: file.h:543
Definition: file.hxx:88
FileStatus(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:685
Definition: file.hxx:56
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
SAL_DLLPUBLIC oslFileError osl_getDirectoryItem(rtl_uString *pustrFileURL, oslDirectoryItem *pItem)
Retrieve a single directory item.
RC open(sal_uInt32 uFlags)
Open a regular file.
Definition: file.hxx:991
inline::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:870
Definition: file.hxx:97
RC reset()
Resets the directory item enumeration to the beginning.
Definition: file.hxx:1773
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
The FileStatus class.
Definition: file.hxx:652
C++ class representing a SAL byte sequence.
Definition: byteseq.h:161
SAL_DLLPUBLIC oslFileError osl_getVolumeInformation(rtl_uString *pustrDirectoryURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask)
Retrieve information about a volume.
Definition: file.h:93
Definition: file.h:341
Definition: file.h:100
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
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:946
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:103
#define osl_FileStatus_Mask_Type
Definition: file.h:366
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:342
SAL_DLLPUBLIC oslFileError osl_releaseVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Release a volume device handle.
sal_uInt32 uMaxNameLength
Maximum length of file name of a single item.
Definition: file.h:582
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1638
SAL_DLLPUBLIC oslFileError osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
Retrieve the next item of a previously opened directory.
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:404
Definition: file.hxx:62
Definition: file.hxx:71
SAL_DLLPUBLIC oslFileError osl_setFileTime(rtl_uString *pustrFileURL, const TimeValue *aCreationTime, const TimeValue *aLastAccessTime, const TimeValue *aLastWriteTime)
Set the file time.
Definition: file.h:91
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1802
Definition: file.hxx:65
Definition: file.h:95
Definition: file.h:89
Definition: file.hxx:96
~File()
Destructor.
Definition: file.hxx:934
SAL_DLLPUBLIC oslFileError osl_getVolumeDeviceMountPath(oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL)
Get the full qualified URL where a device is mounted to.
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:349
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:929
SAL_DLLPUBLIC oslFileError osl_getFileURLFromSystemPath(rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL)
Convert a system dependent path into a file URL.
#define osl_FileStatus_Mask_FileSize
Definition: file.h:371
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:795
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:540
RC close()
Close an open file.
Definition: file.hxx:1010
SAL_DLLPUBLIC oslFileError osl_readLine(oslFileHandle Handle, sal_Sequence **ppSequence)
Read a line from a file.
static RC getTempDirURL(::rtl::OUString &ustrTempDirURL)
Retrieves the file URL of the system's temporary directory path.
Definition: file.hxx:258
rtl_uString * ustrFileSystemName
Points to a string that receives the name of the file system type.
Definition: file.h:587
Definition: file.hxx:81
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1111
Definition: file.h:340
Definition: file.h:114
Definition: file.h:126
RC readLine(::rtl::ByteSequence &aSeq)
Read a line from a file.
Definition: file.hxx:1242
Definition: file.h:131
unsigned char sal_Bool
Definition: types.h:48
#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
Definition: conditn.hxx:28
Definition: file.hxx:83
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1061
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:839
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:613
bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:517
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:810
Definition: file.h:90
Definition: file.h:105
Definition: file.h:106
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
bool isRegular() const
Is it a regular file?
Definition: file.hxx:756
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
Definition: file.h:123
SAL_DLLPUBLIC oslFileError osl_createDirectoryWithFlags(rtl_uString *url, sal_uInt32 flags)
Create a directory, passing flags.
Definition: file.h:112
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1673
struct _oslVolumeInfo oslVolumeInfo
Definition: file.h:345
Definition: file.h:104
Definition: file.hxx:76
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.h:134
Definition: socket_decl.hxx:162
Definition: file.h:115
Definition: file.h:346
Definition: file.h:113
Definition: file.hxx:94
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:391
Type
Definition: file.hxx:669
RC isEndOfFile(sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:1088
Definition: file.h:94
Definition: file.hxx:78
Structure containing information about files and directories.
Definition: file.h:387
Definition: file.hxx:90
Definition: file.h:124
VolumeDevice & operator=(const VolumeDevice &rDevice)
Assignment operator.
Definition: file.hxx:371
sal_uInt64 uAttributes
File attributes.
Definition: file.h:395
RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
Write a number of bytes to a file.
Definition: file.hxx:1212
Definition: file.hxx:70
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1456
rtl_uString * ustrFileURL
Full URL of the file.
Definition: file.h:411
Definition: file.hxx:72
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_uInt64 uFileSize
Size in bytes of the file.
Definition: file.h:405
Definition: file.hxx:57
The directory item class object provides access to file status information.
Definition: file.hxx:1440
#define osl_FileStatus_Mask_Attributes
Definition: file.h:367
SAL_DLLPUBLIC oslFileError osl_getCanonicalName(rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.hxx:676
RC setPos(sal_uInt32 uHow, sal_Int64 uPos) SAL_WARN_UNUSED_RESULT
Set the internal position pointer of an open file.
Definition: file.hxx:1040
Definition: file.hxx:87
#define osl_Volume_Attribute_FixedDisk
Definition: file.h:541
Definition: file.h:132
SAL_DLLPUBLIC oslFileError osl_getFileStatus(oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
Retrieve information about a single file or directory.
Definition: file.hxx:60
Base class for all File System specific objects.
Definition: file.hxx:51
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:1338
VolumeDevice()
Constructor.
Definition: file.hxx:339
void * oslDirectory
Definition: file.h:138
Definition: file.hxx:69
Definition: file.hxx:675
#define osl_Volume_Attribute_CompactDisc
Definition: file.h:540
Definition: file.hxx:59
Definition: file.hxx:95
sal_uInt32 uMaxPathLength
Maximum length of a full quallified path in system notation.
Definition: file.h:584
oslVolumeDeviceHandle * pDeviceHandle
Pointer to handle the receives underlying device.
Definition: file.h:589
Definition: file.h:117
SAL_DLLPUBLIC oslFileError osl_getTempDirURL(rtl_uString **pustrTempDirURL)
Retrieves the file URL of the system's temporary directory path.
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:437
Definition: file.h:109
~DirectoryItem()
Destructor.
Definition: file.hxx:1465
TimeValue aAccessTime
Last access time in nanoseconds since 1/1/1970.
Definition: file.h:401
Definition: file.h:120
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1136
Definition: file.h:102
Definition: file.hxx:67
void * oslVolumeDeviceHandle
Definition: file.h:462
Definition: file.hxx:93
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1712
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
SAL_DLLPUBLIC oslFileError osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos)
Retrieve the current position of the internal pointer of an open file.
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1309
Definition: file.h:101
Definition: file.h:107
Definition: file.hxx:80
Definition: file.h:130
Definition: file.h:99
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:780
SAL_DLLPUBLIC oslFileError osl_acquireDirectoryItem(oslDirectoryItem Item)
Increase the refcount of a directory item handle.
Definition: file.hxx:74
Definition: file.h:87
Definition: file.h:128
SAL_DLLPUBLIC oslFileError osl_setFileAttributes(rtl_uString *pustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
~Directory()
Destructor.
Definition: file.hxx:1680
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.
Definition: file.hxx:100
Definition: file.h:116
sal_uInt32 uAttributes
Attributes of the volume (remote and/or removable)
Definition: file.h:574
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:1692
oslFileType eType
The type of the file (file, directory, volume).
Definition: file.h:393
bool getCompactDiscFlag() const
Check the compact disc flag.
Definition: file.hxx:495
static RC getVolumeInfo(const ::rtl::OUString &ustrDirectoryURL, VolumeInfo &rInfo)
Retrieve information about a volume.
Definition: file.hxx:1844
#define OSL_PRECOND(c, m)
Definition: diagnose.h:111
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:713
sal_uInt64 uFreeSpace
Free space on the volume for the current process/user.
Definition: file.h:580
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.
Definition: file.hxx:671
Definition: file.h:118
SAL_DLLPUBLIC oslFileError osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:101
RC close()
Close a directory.
Definition: file.hxx:1742
~FileStatus()
Destructor.
Definition: file.hxx:694
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath,::rtl::OUString &ustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.hxx:210
Definition: file.h:119
Definition: file.hxx:75
Definition: file.h:347
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
#define osl_FileStatus_Mask_FileName
Definition: file.h:372
Definition: file.hxx:92
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:588
Definition: file.hxx:79
Definition: file.h:108
static RC createPath(const ::rtl::OUString &aDirectoryUrl, DirectoryCreationObserver *aDirectoryCreationObserver=NULL)
Create a directory path.
Definition: file.hxx:1973
Main goals and usage hints.
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1621
Definition: file.h:122
#define osl_FileStatus_Mask_ModifyTime
Definition: file.h:370
RC
Definition: file.hxx:55
SAL_DLLPUBLIC oslFileError osl_acquireVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Acquire a volume device handle.
Definition: file.hxx:673
sal_uInt64 getUsedSpace() const
Determine the used space of a volume device.
Definition: file.hxx:564
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:403
Definition: file.h:344
bool is()
Check for validity of this instance.
Definition: file.hxx:1495
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:576
bool isCaseSensitiveFileSystem() const
Return whether the file system is case sensitive or case insensitive.
Definition: file.hxx:624
SAL_DLLPUBLIC oslFileError osl_releaseDirectoryItem(oslDirectoryItem Item)
Decrease the refcount of a directory item handle.
SAL_DLLPUBLIC oslFileError osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
bool isOpen()
Query if directory is open.
Definition: file.hxx:1728
Definition: file.hxx:73
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
SAL_DLLPUBLIC oslFileError osl_moveFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Move a file or directory to a new destination or renames it.
SAL_DLLPUBLIC oslFileError osl_openDirectory(rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory)
Open a directory for enumerating its contents.
sal_uInt64 uUsedSpace
Used space on the volume for the current process/user.
Definition: file.h:578
Base class for observers of directory creation notifications.
Definition: file.hxx:1618
DirectoryItem()
Constructor.
Definition: file.hxx:1449
Definition: file.h:121
bool isCasePreservingFileSystem() const
Return whether the file system preserves the case of file and directory names or not.
Definition: file.hxx:636
Definition: file.hxx:66
Definition: file.hxx:102
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:462
Definition: file.h:133
Definition: file.h:125
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:374
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...
The VolumeInfo class.
Definition: file.hxx:413
Definition: file.hxx:63
SAL_DLLPUBLIC oslFileError osl_openFile(rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags)
Open a regular file.
rtl_uString * ustrLinkTargetURL
Full URL of the target file if the file itself is a link.
Definition: file.h:415
Definition: file.h:88
#define osl_FileStatus_Mask_CreationTime
Definition: file.h:368
Definition: file.h:96
Definition: file.hxx:99
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:398
#define osl_File_OpenFlag_Write
Definition: file.h:639
The file class object provides access to file contents and attributes.
Definition: file.hxx:906
bool isLink() const
Is it a link?
Definition: file.hxx:769
bool isDirectory() const
Is it a directory? This method returns True for both directories, and volumes.
Definition: file.hxx:741
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:408
#define osl_Volume_Attribute_Remote
Definition: file.h:539
static RC setTime(const ::rtl::OUString &ustrFileURL, const TimeValue &rCreationTime, const TimeValue &rLastAccessTime, const TimeValue &rLastWriteTime)
Set the file time.
Definition: file.hxx:1418
oslFileError
Definition: file.h:86
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.h:110
inline::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:886
Definition: file.hxx:677
Definition: file.hxx:672
Definition: file.hxx:77
Definition: file.h:343
#define osl_FileStatus_Mask_FileURL
Definition: file.h:373
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:391
Definition: file.h:97
Definition: file.hxx:61
Definition: file.hxx:91
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1577
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:115
Definition: file.hxx:84
static RC create(const ::rtl::OUString &ustrDirectoryURL, sal_uInt32 flags=osl_File_OpenFlag_Read|osl_File_OpenFlag_Write)
Create a directory.
Definition: file.hxx:1880
Definition: file.h:92
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1173
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:319
Definition: file.h:111
Definition: file.hxx:86
Definition: time.h:42
SAL_DLLPUBLIC oslFileError osl_copyFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:89
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:545
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:825
bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:528
Type getFileType() const
Get the file type.
Definition: file.hxx:723
Definition: file.hxx:98
~VolumeDevice()
Destructor.
Definition: file.hxx:359
Definition: file.h:103
Definition: file.hxx:68
SAL_DLLPUBLIC sal_Bool osl_identicalDirectoryItem(oslDirectoryItem pItemA, oslDirectoryItem pItemB)
Determine if two directory items point the same underlying file.
bool getRemoveableFlag() const
Check the removeable flag.
Definition: file.hxx:484
inline::rtl::OUString getFileSystemName() const
Determine the name of the volume device's File System.
Definition: file.hxx:600
SAL_DLLPUBLIC oslFileError osl_removeDirectory(rtl_uString *pustrDirectoryURL)
Remove an empty directory.
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1277
The directory class object provides a enumeration of DirectoryItems.
Definition: file.hxx:1649
inline::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:853
#define osl_Volume_Attribute_Removeable
Definition: file.h:538
static RC setAttributes(const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:1391
Definition: file.hxx:64
Definition: file.h:98
void * oslFileHandle
Definition: file.h:634
~VolumeInfo()
Destructor.
Definition: file.hxx:448
SAL_DLLPUBLIC oslFileError osl_readFile(oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead)
Read a number of bytes from a file.
SAL_DLLPUBLIC oslFileError osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize)
Get the file size of an open file.
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:552
Structure containing information about volumes.
Definition: file.h:568
The VolumeDevice class.
Definition: file.hxx:330