LibreOffice
LibreOffice 6.0 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 
51 class FileBase
52 {
53 public:
54 
55  enum RC {
104  };
105 
106 
107 public:
108 
129  static RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
130  {
131  return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
132  }
133 
168  static 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 
187  static RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
188  {
189  return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
190  }
191 
206  static RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
207  {
208  return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
209  }
210 
238  static RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
239  {
240  return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
241  }
242 
252  static RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
253  {
254  return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
255  }
256 
305  ::rtl::OUString* pustrDirectoryURL,
306  oslFileHandle* pHandle,
307  ::rtl::OUString* pustrTempFileURL)
308  {
309  rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : NULL;
310  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : NULL;
311 
312  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
313  }
314 };
315 
316 
322 class VolumeDevice : public FileBase
323 {
324  oslVolumeDeviceHandle _aHandle;
325 
326 public:
327 
331  VolumeDevice() : _aHandle( NULL )
332  {
333  }
334 
341  VolumeDevice( const VolumeDevice & rDevice )
342  {
343  _aHandle = rDevice._aHandle;
344  if ( _aHandle )
345  osl_acquireVolumeDeviceHandle( _aHandle );
346  }
347 
352  {
353  if ( _aHandle )
354  osl_releaseVolumeDeviceHandle( _aHandle );
355  }
356 
363  VolumeDevice & operator =( const VolumeDevice & rDevice )
364  {
365  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
366 
367  if ( newHandle )
368  osl_acquireVolumeDeviceHandle( newHandle );
369 
370  if ( _aHandle )
371  osl_releaseVolumeDeviceHandle( _aHandle );
372 
373  _aHandle = newHandle;
374 
375  return *this;
376  }
377 
384  {
385  rtl::OUString aPath;
386  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
387  return aPath;
388  }
389 
390  friend class VolumeInfo;
391 };
392 
393 
394 class Directory;
395 
405 {
406  oslVolumeInfo _aInfo;
407  sal_uInt32 _nMask;
408  VolumeDevice _aDevice;
409 
414 
418  VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
419 
420 public:
421 
427  VolumeInfo( sal_uInt32 nMask )
428  : _nMask( nMask )
429  {
430  memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
431  _aInfo.uStructSize = sizeof( oslVolumeInfo );
432  _aInfo.pDeviceHandle = &_aDevice._aHandle;
433  }
434 
436  {
437  if( _aInfo.ustrFileSystemName )
439  }
440 
448  bool isValid( sal_uInt32 nMask ) const
449  {
450  return ( nMask & _aInfo.uValidFields ) == nMask;
451  }
452 
458  bool getRemoteFlag() const
459  {
460  return (_aInfo.uAttributes & osl_Volume_Attribute_Remote) != 0;
461  }
462 
468  bool getRemoveableFlag() const
469  {
470  return (_aInfo.uAttributes & osl_Volume_Attribute_Removeable) != 0;
471  }
472 
479  bool getCompactDiscFlag() const
480  {
481  return (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc) != 0;
482  }
483 
490  bool getFloppyDiskFlag() const
491  {
492  return (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk) != 0;
493  }
494 
501  bool getFixedDiskFlag() const
502  {
503  return (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk) != 0;
504  }
505 
512  bool getRAMDiskFlag() const
513  {
514  return (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk) != 0;
515  }
516 
524  sal_uInt64 getTotalSpace() const
525  {
526  return _aInfo.uTotalSpace;
527  }
528 
536  sal_uInt64 getFreeSpace() const
537  {
538  return _aInfo.uFreeSpace;
539  }
540 
548  sal_uInt64 getUsedSpace() const
549  {
550  return _aInfo.uUsedSpace;
551  }
552 
560  sal_uInt32 getMaxNameLength() const
561  {
562  return _aInfo.uMaxNameLength;
563  }
564 
572  sal_uInt32 getMaxPathLength() const
573  {
574  return _aInfo.uMaxPathLength;
575  }
576 
585  {
587  }
588 
589 
598  {
599  return _aDevice;
600  }
601 
609  {
610  return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
611  }
612 
621  {
623  }
624 
625  friend class Directory;
626 };
627 
628 
629 class DirectoryItem;
630 
637 {
638  oslFileStatus _aStatus;
639  sal_uInt32 _nMask;
640 
645 
649  FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
650 
651 public:
652 
653  enum Type {
662  };
663 
669  FileStatus(sal_uInt32 nMask)
670  : _nMask(nMask)
671  {
672  memset(&_aStatus, 0, sizeof(_aStatus));
673  _aStatus.uStructSize = sizeof(_aStatus);
674  }
675 
679  {
680  if ( _aStatus.ustrFileURL )
681  rtl_uString_release( _aStatus.ustrFileURL );
682  if ( _aStatus.ustrLinkTargetURL )
684  if ( _aStatus.ustrFileName )
685  rtl_uString_release( _aStatus.ustrFileName );
686  }
687 
697  bool isValid( sal_uInt32 nMask ) const
698  {
699  return ( nMask & _aStatus.uValidFields ) == nMask;
700  }
701 
708  {
709  SAL_INFO_IF(
710  !isValid(osl_FileStatus_Mask_Type), "sal.osl",
711  "no FileStatus Type determined");
712  return isValid(osl_FileStatus_Mask_Type)
713  ? static_cast< Type >(_aStatus.eType) : Unknown;
714  }
715 
725  bool isDirectory() const
726  {
727  return ( getFileType() == Directory || getFileType() == Volume );
728  }
729 
740  bool isRegular() const
741  {
742  return ( getFileType() == Regular );
743  }
744 
753  bool isLink() const
754  {
755  return ( getFileType() == Link );
756  }
757 
764  sal_uInt64 getAttributes() const
765  {
766  SAL_INFO_IF(
767  !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
768  "no FileStatus Attributes determined");
769  return _aStatus.uAttributes;
770  }
771 
780  {
781  SAL_INFO_IF(
782  !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
783  "no FileStatus CreationTime determined");
784  return _aStatus.aCreationTime;
785  }
786 
795  {
796  SAL_INFO_IF(
797  !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
798  "no FileStatus AccessTime determined");
799  return _aStatus.aAccessTime;
800  }
801 
810  {
811  SAL_INFO_IF(
812  !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
813  "no FileStatus ModifyTime determined");
814  return _aStatus.aModifyTime;
815  }
816 
823  sal_uInt64 getFileSize() const
824  {
825  SAL_INFO_IF(
826  !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
827  "no FileStatus FileSize determined");
828  return _aStatus.uFileSize;
829  }
830 
838  {
839  SAL_INFO_IF(
840  !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
841  "no FileStatus FileName determined");
842  return isValid(osl_FileStatus_Mask_FileName)
843  ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
844  }
845 
846 
855  {
856  SAL_INFO_IF(
857  !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
858  "no FileStatus FileURL determined");
859  return isValid(osl_FileStatus_Mask_FileURL)
860  ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
861  }
862 
871  {
872  SAL_INFO_IF(
873  !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
874  "no FileStatus LinkTargetURL determined");
875  return isValid(osl_FileStatus_Mask_LinkTargetURL)
877  }
878 
879  friend class DirectoryItem;
880 };
881 
882 
889 class File: public FileBase
890 {
891  oslFileHandle _pData;
892  ::rtl::OUString _aPath;
893 
898 
902  File& operator = ( File& ) SAL_DELETED_FUNCTION;
903 
904 public:
905 
912  File( const ::rtl::OUString& ustrFileURL ): _pData( NULL ), _aPath( ustrFileURL ) {}
913 
918  {
919  close();
920  }
921 
929  rtl::OUString getURL() const { return _aPath; }
930 
973  RC open( sal_uInt32 uFlags )
974  {
975  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
976  }
977 
992  {
994 
995  if( _pData )
996  {
997  Error=osl_closeFile( _pData );
998  _pData = NULL;
999  }
1000 
1001  return static_cast< RC >( Error );
1002  }
1003 
1020  RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
1021  {
1022  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1023  }
1024 
1040  RC getPos( sal_uInt64& uPos )
1041  {
1042  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1043  }
1044 
1067  {
1068  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1069  }
1070 
1088  RC setSize( sal_uInt64 uSize )
1089  {
1090  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1091  }
1092 
1112  RC getSize( sal_uInt64 &rSize )
1113  {
1114  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1115  }
1116 
1148  RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1149  {
1150  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1151  }
1152 
1186  RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1187  {
1188  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1189  }
1190 
1191 
1216  {
1217  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1218  }
1219 
1239  RC sync() const
1240  {
1241  OSL_PRECOND(_pData, "File::sync(): File not open");
1242  return static_cast< RC >(osl_syncFile(_pData));
1243  }
1244 
1270  static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1271  {
1272  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1273  }
1274 
1298  static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1299  {
1300  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1301  }
1302 
1330  static RC remove( const ::rtl::OUString& ustrFileURL )
1331  {
1332  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1333  }
1334 
1350  static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1351  {
1352  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1353  }
1354 
1376  static RC setTime(
1377  const ::rtl::OUString& ustrFileURL,
1378  const TimeValue& rCreationTime,
1379  const TimeValue& rLastAccessTime,
1380  const TimeValue& rLastWriteTime )
1381  {
1382  return static_cast< RC >( osl_setFileTime(
1383  ustrFileURL.pData,
1384  &rCreationTime,
1385  &rLastAccessTime,
1386  &rLastWriteTime ) );
1387  }
1388 
1389  friend class DirectoryItem;
1390 };
1391 
1392 
1399 {
1400  oslDirectoryItem _pData;
1401 
1402 public:
1403 
1407  DirectoryItem(): _pData( NULL )
1408  {
1409  }
1410 
1414  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1415  {
1416  if( _pData )
1417  osl_acquireDirectoryItem( _pData );
1418  }
1419 
1424  {
1425  if( _pData )
1426  osl_releaseDirectoryItem( _pData );
1427  }
1428 
1433  {
1434  if (&rItem != this)
1435  {
1436  if( _pData )
1437  osl_releaseDirectoryItem( _pData );
1438 
1439  _pData = rItem._pData;
1440 
1441  if( _pData )
1442  osl_acquireDirectoryItem( _pData );
1443  }
1444  return *this;
1445  }
1446 
1453  bool is()
1454  {
1455  return _pData != NULL;
1456  }
1457 
1491  static RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1492  {
1493  if( rItem._pData)
1494  {
1495  osl_releaseDirectoryItem( rItem._pData );
1496  rItem._pData = NULL;
1497  }
1498 
1499  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1500  }
1501 
1534  {
1535  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1536  }
1537 
1553  bool isIdenticalTo( const DirectoryItem &pOther )
1554  {
1555  return osl_identicalDirectoryItem( _pData, pOther._pData );
1556  }
1557 
1558  friend class Directory;
1559 };
1560 
1561 
1573 {
1574 public:
1576 
1586  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1587 };
1588 
1589 
1590 // This just an internal helper function for
1591 // private use.
1592 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1593 {
1594  static_cast<DirectoryCreationObserver*>(pData)->DirectoryCreated(aDirectoryUrl);
1595 }
1596 
1603 class Directory: public FileBase
1604 {
1605  oslDirectory _pData;
1606  ::rtl::OUString _aPath;
1607 
1612 
1616  Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1617 
1618 public:
1619 
1627  Directory( const ::rtl::OUString& strPath ): _pData( NULL ), _aPath( strPath )
1628  {
1629  }
1630 
1635  {
1636  close();
1637  }
1638 
1646  rtl::OUString getURL() const { return _aPath; }
1647 
1666  {
1667  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1668  }
1669 
1680  bool isOpen() { return _pData != NULL; }
1681 
1694  {
1695  oslFileError Error = osl_File_E_BADF;
1696 
1697  if( _pData )
1698  {
1699  Error=osl_closeDirectory( _pData );
1700  _pData = NULL;
1701  }
1702 
1703  return static_cast< RC >( Error );
1704  }
1705 
1706 
1724  {
1725  close();
1726  return open();
1727  }
1728 
1751  RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1752  {
1753  if( rItem._pData )
1754  {
1755  osl_releaseDirectoryItem( rItem._pData );
1756  rItem._pData = NULL;
1757  }
1758  return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
1759  }
1760 
1761 
1792  static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1793  {
1794  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1795  }
1796 
1827  static RC create(
1828  const ::rtl::OUString& ustrDirectoryURL,
1829  sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1830  {
1831  return static_cast< RC >(
1832  osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1833  }
1834 
1862  static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1863  {
1864  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1865  }
1866 
1903  static RC createPath(
1904  const ::rtl::OUString& aDirectoryUrl,
1905  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1906  {
1907  return static_cast< RC >(osl_createDirectoryPath(
1908  aDirectoryUrl.pData,
1909  (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
1910  aDirectoryCreationObserver));
1911  }
1912 };
1913 
1914 } /* namespace osl */
1915 
1916 #endif // INCLUDED_OSL_FILE_HXX
1917 
1918 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
filename too long
Definition: file.hxx:90
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1751
#define osl_File_OpenFlag_Read
Definition: file.h:626
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:559
#define SAL_INFO_IF(condition, area, stream)
Produce log entry from stream in the given log area if condition is true.
Definition: log.hxx:307
SAL_DLLPUBLIC oslFileError osl_getTempDirURL(rtl_uString **pustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:383
bool isRegular() const
Is it a regular file?
Definition: file.hxx:740
Definition: file.h:131
operation not permitted
Definition: file.hxx:57
function not implemented
Definition: file.hxx:92
value too large for defined data type
Definition: file.hxx:99
too many levels of symbolic links found during name lookup
Definition: file.hxx:94
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:929
SAL_DLLPUBLIC oslFileError osl_readLine(oslFileHandle Handle, sal_Sequence **ppSequence)
Read a line from a file.
Base class for all File System specific objects.
Definition: file.hxx:51
Definition: file.h:114
RC open(sal_uInt32 uFlags)
Open a regular file.
Definition: file.hxx:973
Definition: file.h:122
Definition: file.h:99
oslVolumeDeviceHandle * pDeviceHandle
Pointer to handle the receives underlying device.
Definition: file.h:580
Type
Definition: file.hxx:653
Definition: file.h:97
static RC getSystemPathFromFileURL(const ::rtl::OUString &ustrFileURL,::rtl::OUString &ustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:187
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:1298
TimeValue aAccessTime
Last access time in nanoseconds since 1/1/1970.
Definition: file.h:390
Definition: file.h:111
no process matches the PID
Definition: file.hxx:59
SAL_DLLPUBLIC oslFileError osl_setFileAttributes(rtl_uString *pustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
invalid or incomplete byte sequence of multibyte char found
Definition: file.hxx:95
Definition: file.h:89
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.
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:304
static RC setTime(const ::rtl::OUString &ustrFileURL, const TimeValue &rCreationTime, const TimeValue &rLastAccessTime, const TimeValue &rLastWriteTime)
Set the file time.
Definition: file.hxx:1376
argument list too long
Definition: file.hxx:63
I/O error occurred.
Definition: file.hxx:61
resource temp unavailable, try again later
Definition: file.hxx:67
SAL_DLLPUBLIC oslFileError osl_releaseVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Release a volume device handle.
directory not empty
Definition: file.hxx:93
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:561
illegal modification to read-only filesystem
Definition: file.hxx:84
Definition: file.h:125
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1592
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:402
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:809
~Directory()
Destructor.
Definition: file.hxx:1634
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:697
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:366
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1665
The directory item class object provides access to file status information.
Definition: file.hxx:1398
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:392
wrong device type specified
Definition: file.hxx:74
SAL_DLLPUBLIC oslFileError osl_createTempFile(rtl_uString *pustrDirectoryURL, oslFileHandle *pHandle, rtl_uString **ppustrTempFileURL)
Creates a temporary file in the directory provided by the caller or the directory returned by osl_get...
Definition: file.h:126
Definition: file.h:326
bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:501
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:137
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:536
void * oslFileHandle
Definition: file.h:622
RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
Write a number of bytes to a file.
Definition: file.hxx:1186
bool isLink() const
Is it a link?
Definition: file.hxx:753
Definition: file.h:113
Definition: file.h:92
Definition: file.h:95
static RC getTempDirURL(::rtl::OUString &ustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
Definition: file.hxx:252
sal_uInt64 uFreeSpace
Free space on the volume for the current process/user.
Definition: file.h:569
#define osl_Volume_Attribute_RAMDisk
Definition: file.h:526
Definition: file.h:90
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:427
#define osl_File_OpenFlag_Write
Definition: file.h:627
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:854
Definition: file.h:109
#define OSL_PRECOND(c, m)
Check the precondition of functions.
Definition: diagnose.h:109
SAL_DLLPUBLIC oslFileError osl_setFileTime(rtl_uString *pustrFileURL, const TimeValue *aCreationTime, const TimeValue *aLastAccessTime, const TimeValue *aLastWriteTime)
Set the file time.
Definition: file.h:325
bool getRemoteFlag() const
Check the remote flag.
Definition: file.hxx:458
no such file or directory
Definition: file.hxx:58
file isn&#39;t a directory where one is needed
Definition: file.hxx:75
Definition: file.h:94
bool getFloppyDiskFlag() const
Check the floppy disc flag.
Definition: file.hxx:490
#define osl_FileStatus_Mask_CreationTime
Definition: file.h:360
FileStatus(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:669
broken pipe; no process reading from other end of pipe
Definition: file.hxx:86
Definition: file.h:91
deadlock avoided
Definition: file.hxx:89
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:341
file quote system is confused as there are too many users
Definition: file.hxx:98
Definition: file.h:88
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1533
no memory available
Definition: file.hxx:68
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:764
bool is()
Check for validity of this instance.
Definition: file.hxx:1453
on success
Definition: file.hxx:56
Definition: file.h:104
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:110
#define osl_FileStatus_Mask_ModifyTime
Definition: file.h:362
RC close()
Close an open file.
Definition: file.hxx:991
Definition: file.h:324
Main goals and usage hints.
::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:837
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:1646
RC setPos(sal_uInt32 uHow, sal_Int64 uPos) SAL_WARN_UNUSED_RESULT
Set the internal position pointer of an open file.
Definition: file.hxx:1020
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:380
Definition: file.hxx:103
#define osl_Volume_Attribute_CompactDisc
Definition: file.h:524
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1040
#define osl_FileStatus_Mask_FileName
Definition: file.h:364
unsigned char sal_Bool
Definition: types.h:39
Definition: file.h:107
static RC create(const ::rtl::OUString &ustrDirectoryURL, sal_uInt32 flags=osl_File_OpenFlag_Read|osl_File_OpenFlag_Write)
Create a directory.
Definition: file.hxx:1827
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:387
no such device or address
Definition: file.hxx:62
VolumeDevice()
Constructor.
Definition: file.hxx:331
Base class for observers of directory creation notifications.
Definition: file.hxx:1572
oslFileType eType
The type of the file (file, directory, volume).
Definition: file.h:382
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1627
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:397
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:779
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:912
Definition: file.h:102
range error (mathematical error)
Definition: file.hxx:88
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1432
struct _oslVolumeInfo oslVolumeInfo
Structure containing information about volumes.
The VolumeInfo class.
Definition: file.hxx:404
The file class object provides access to file contents and attributes.
Definition: file.hxx:889
bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1553
Definition: file.h:96
Definition: file.h:132
SAL_DLLPUBLIC oslFileError osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.h:323
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:572
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
Definition: file.h:328
Definition: file.h:118
SAL_DLLPUBLIC oslFileError osl_getFileStatus(oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
Retrieve information about a single file or directory.
improper link across file systems detected
Definition: file.hxx:73
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:597
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:794
#define osl_Volume_Attribute_Remote
Definition: file.h:523
RC
Definition: file.hxx:55
rtl_uString * ustrLinkTargetURL
Full URL of the target file if the file itself is a link.
Definition: file.h:404
Definition: file.h:106
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:560
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:307
invalid argument to library function
Definition: file.hxx:77
Definition: file.h:120
there are no child processes
Definition: file.hxx:66
#define osl_Volume_Attribute_Removeable
Definition: file.h:522
socket operation timed out
Definition: file.hxx:102
link has been severed
Definition: file.hxx:96
SAL_DLLPUBLIC oslFileError osl_openDirectory(rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory)
Open a directory for enumerating its contents.
sal_uInt32 uMaxNameLength
Maximum length of file name of a single item.
Definition: file.h:571
bool getCompactDiscFlag() const
Check the compact disc flag.
Definition: file.hxx:479
sal_uInt64 uUsedSpace
Used space on the volume for the current process/user.
Definition: file.h:567
DirectoryItem()
Constructor.
Definition: file.hxx:1407
bool isCasePreservingFileSystem() const
Return whether the file system preserves the case of file and directory names or not.
Definition: file.hxx:620
#define osl_FileStatus_Mask_Attributes
Definition: file.h:359
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:448
void * oslDirectoryItem
Definition: file.h:138
Definition: file.h:128
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
void * oslVolumeDeviceHandle
Definition: file.h:448
bool isOpen()
Query if directory is open.
Definition: file.hxx:1680
#define osl_FileStatus_Mask_Type
Definition: file.h:358
RC reset()
Resets the directory item enumeration to the beginning.
Definition: file.hxx:1723
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:378
bool isDirectory() const
Is it a directory? This method returns True for both directories, and volumes.
Definition: file.hxx:725
SAL_DLLPUBLIC oslFileError osl_getFileURLFromSystemPath(rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL)
Convert a system dependent path into a file URL.
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:238
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1148
invalid executable file format
Definition: file.hxx:64
oslFileError
Definition: file.h:85
Definition: file.h:93
static RC createPath(const ::rtl::OUString &aDirectoryUrl, DirectoryCreationObserver *aDirectoryCreationObserver=NULL)
Create a directory path.
Definition: file.hxx:1903
no locks available
Definition: file.hxx:91
bad address; an invalid pointer detected
Definition: file.hxx:70
Definition: file.h:87
sal_uInt64 uTotalSpace
Total available space on the volume for the current process/user.
Definition: file.h:565
Definition: file.h:330
SAL_DLLPUBLIC oslFileError osl_readFile(oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead)
Read a number of bytes from a file.
RC readLine(::rtl::ByteSequence &aSeq)
Read a line from a file.
Definition: file.hxx:1215
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath,::rtl::OUString &ustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.hxx:206
SAL_DLLPUBLIC oslFileError osl_syncFile(oslFileHandle Handle)
Synchronize the memory representation of a file with that on the physical medium. ...
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:823
#define osl_Volume_Attribute_FixedDisk
Definition: file.h:525
SAL_DLLPUBLIC oslFileError osl_acquireVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Acquire a volume device handle.
RC close()
Close a directory.
Definition: file.hxx:1693
Definition: file.h:108
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1270
Definition: file.h:117
Definition: file.h:101
#define osl_FileStatus_Mask_FileSize
Definition: file.h:363
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:120
SAL_DLLPUBLIC oslFileError osl_releaseDirectoryItem(oslDirectoryItem Item)
Decrease the refcount of a directory item handle.
function call was interrupted
Definition: file.hxx:60
too many distinct file openings
Definition: file.hxx:78
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
Definition: file.h:105
file permissions do not allow operation
Definition: file.hxx:69
Definition: file.h:327
#define osl_Volume_Attribute_Case_Sensitive
Definition: file.h:530
SAL_DLLPUBLIC oslFileError osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize)
Get the file size of an open file.
bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:512
Type getFileType() const
Get the file type.
Definition: file.hxx:707
Definition: time.h:66
SAL_DLLPUBLIC sal_Bool osl_identicalDirectoryItem(oslDirectoryItem pItemA, oslDirectoryItem pItemB)
Determine if two directory items point the same underlying file.
Definition: file.h:124
Definition: file.h:329
#define osl_FileStatus_Mask_FileURL
Definition: file.h:365
::rtl::OUString getFileSystemName() const
Determine the name of the volume device&#39;s File System.
Definition: file.hxx:584
Definition: file.h:121
C++ class representing a SAL byte sequence.
Definition: byteseq.h:165
RC isEndOfFile(sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:1066
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1112
file exists where should only be created
Definition: file.hxx:72
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1575
no space left on device, write failed
Definition: file.hxx:82
The directory class object provides a enumeration of DirectoryItems.
Definition: file.hxx:1603
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_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
too many links to file
Definition: file.hxx:85
rtl_uString * ustrFileSystemName
Points to a string that receives the name of the file system type.
Definition: file.h:577
sal_uInt32 uMaxPathLength
Maximum length of a full qualified path in system notation.
Definition: file.h:573
sal_uInt64 getUsedSpace() const
Determine the used space of a volume device.
Definition: file.hxx:548
SAL_DLLPUBLIC oslFileError osl_acquireDirectoryItem(oslDirectoryItem Item)
Increase the refcount of a directory item handle.
Structure containing information about volumes.
Definition: file.h:556
bool isCaseSensitiveFileSystem() const
Return whether the file system is case sensitive or case insensitive.
Definition: file.hxx:608
domain error (mathematical error)
Definition: file.hxx:87
Definition: file.h:129
The VolumeDevice class.
Definition: file.hxx:322
static RC getVolumeInfo(const ::rtl::OUString &ustrDirectoryURL, VolumeInfo &rInfo)
Retrieve information about a volume.
Definition: file.hxx:1792
SAL_DLLPUBLIC oslFileError osl_searchFileURL(rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL)
Search a full qualified system path or a file URL.
inappropriate I/O control operation
Definition: file.hxx:80
Definition: file.h:112
SAL_DLLPUBLIC oslFileError osl_createDirectoryWithFlags(rtl_uString *url, sal_uInt32 flags)
Create a directory, passing flags.
remote resource is not directly available
Definition: file.hxx:97
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1088
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1239
device not ready
Definition: file.hxx:100
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_getDirectoryItem(rtl_uString *pustrFileURL, oslDirectoryItem *pItem)
Retrieve a single directory item.
~FileStatus()
Destructor.
Definition: file.hxx:678
SAL_DLLPUBLIC oslFileError osl_copyFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Copy a file to a new destination.
file too large
Definition: file.hxx:81
Definition: file.h:115
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
Definition: file.h:98
unmapped error: always last entry in enum!
Definition: file.hxx:101
The FileStatus class.
Definition: file.hxx:636
resource busy
Definition: file.hxx:71
Definition: file.h:119
bad file descriptor
Definition: file.hxx:65
#define osl_Volume_Attribute_FloppyDisk
Definition: file.h:527
Definition: file.h:103
rtl_uString * ustrFileURL
Full URL of the file.
Definition: file.h:400
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:529
Definition: file.h:133
SAL_DLLPUBLIC oslFileError osl_getVolumeInformation(rtl_uString *pustrDirectoryURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask)
Retrieve information about a volume.
#define osl_FileStatus_Mask_AccessTime
Definition: file.h:361
SAL_DLLPUBLIC oslFileError osl_openFile(rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags)
Open a regular file.
Definition: conditn.hxx:36
~DirectoryItem()
Destructor.
Definition: file.hxx:1423
~VolumeDevice()
Destructor.
Definition: file.hxx:351
Definition: file.h:86
bool getRemoveableFlag() const
Check the removeable flag.
Definition: file.hxx:468
Definition: file.h:127
sal_uInt32 uAttributes
Attributes of the volume (remote and/or removable)
Definition: file.h:563
Definition: file.h:123
file is a directory, invalid operation
Definition: file.hxx:76
~VolumeInfo()
Definition: file.hxx:435
Definition: file.h:100
Definition: file.h:130
process has too many distinct files open
Definition: file.hxx:79
::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:870
~File()
Destructor.
Definition: file.hxx:917
Definition: socket_decl.hxx:191
static RC getCanonicalName(const ::rtl::OUString &ustrRequestedURL,::rtl::OUString &ustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.hxx:129
sal_uInt64 getTotalSpace() const
Determine the total space of a volume device.
Definition: file.hxx:524
SAL_DLLPUBLIC oslFileError osl_getCanonicalName(rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL)
Determine a valid unused canonical name for a requested name.
SAL_DLLPUBLIC oslFileError osl_removeDirectory(rtl_uString *pustrDirectoryURL)
Remove an empty directory.
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1414
sal_uInt64 uFileSize
Size in bytes of the file.
Definition: file.h:394
sal_uInt64 uAttributes
File attributes.
Definition: file.h:384
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.h:116
SAL_DLLPUBLIC oslFileError osl_writeFile(oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten)
Write a number of bytes to a file.
invalid seek operation (such as on pipe)
Definition: file.hxx:83
Structure containing information about files and directories.
Definition: file.h:376
static RC setAttributes(const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:1350