LibreOffice
LibreOffice 25.2 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 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_OSL_FILE_HXX
25 #define INCLUDED_OSL_FILE_HXX
26 
27 #include "sal/config.h"
28 
29 #include <string.h>
30 
31 #include <cstddef>
32 
33 #include "sal/log.hxx"
34 #include "osl/time.h"
35 #include "rtl/ustring.hxx"
36 
37 #include "osl/file.h"
38 
39 namespace rtl { class ByteSequence; }
40 
41 namespace osl
42 {
43 
44 
52 class FileBase
53 {
54 public:
55 
56  enum RC {
105  };
106 
107 
108 public:
109 
130  static RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
131  {
132  return static_cast< RC >( osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData ) );
133  }
134 
169  static RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
170  {
171  return static_cast< RC >( osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData ) );
172  }
173 
188  static RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
189  {
190  return static_cast< RC >( osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData ) );
191  }
192 
207  static RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
208  {
209  return static_cast< RC >( osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData ) );
210  }
211 
239  static RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
240  {
241  return static_cast< RC >( osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData ) );
242  }
243 
253  static RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
254  {
255  return static_cast< RC >( osl_getTempDirURL( &ustrTempDirURL.pData ) );
256  }
257 
306  ::rtl::OUString* pustrDirectoryURL,
307  oslFileHandle* pHandle,
308  ::rtl::OUString* pustrTempFileURL)
309  {
310  rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : NULL;
311  rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : NULL;
312 
313  return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url) );
314  }
315 };
316 
317 
323 class VolumeDevice : public FileBase
324 {
325  oslVolumeDeviceHandle _aHandle;
326 
327 public:
328 
332  VolumeDevice() : _aHandle( NULL )
333  {
334  }
335 
342  VolumeDevice( const VolumeDevice & rDevice )
343  {
344  _aHandle = rDevice._aHandle;
345  if ( _aHandle )
346  osl_acquireVolumeDeviceHandle( _aHandle );
347  }
348 
353  {
354  if ( _aHandle )
355  osl_releaseVolumeDeviceHandle( _aHandle );
356  }
357 
364  VolumeDevice & operator =( const VolumeDevice & rDevice )
365  {
366  oslVolumeDeviceHandle newHandle = rDevice._aHandle;
367 
368  if ( newHandle )
369  osl_acquireVolumeDeviceHandle( newHandle );
370 
371  if ( _aHandle )
372  osl_releaseVolumeDeviceHandle( _aHandle );
373 
374  _aHandle = newHandle;
375 
376  return *this;
377  }
378 
385  {
386  rtl::OUString aPath;
387  osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
388  return aPath;
389  }
390 
391  friend class VolumeInfo;
392 };
393 
394 
395 class Directory;
396 
406 {
407  oslVolumeInfo _aInfo;
408  sal_uInt32 _nMask;
409  VolumeDevice _aDevice;
410 
415 
419  VolumeInfo& operator = ( VolumeInfo& ) SAL_DELETED_FUNCTION;
420 
421 public:
422 
428  VolumeInfo( sal_uInt32 nMask )
429  : _nMask( nMask )
430  {
431  memset( &_aInfo, 0, sizeof( oslVolumeInfo ));
432  _aInfo.uStructSize = sizeof( oslVolumeInfo );
433  _aInfo.pDeviceHandle = &_aDevice._aHandle;
434  }
435 
437  {
438  if( _aInfo.ustrFileSystemName )
440  }
441 
449  bool isValid( sal_uInt32 nMask ) const
450  {
451  return ( nMask & _aInfo.uValidFields ) == nMask;
452  }
453 
459  bool getRemoteFlag() const
460  {
461  return (_aInfo.uAttributes & osl_Volume_Attribute_Remote) != 0;
462  }
463 
469  bool getRemoveableFlag() const
470  {
471  return (_aInfo.uAttributes & osl_Volume_Attribute_Removeable) != 0;
472  }
473 
480  bool getCompactDiscFlag() const
481  {
482  return (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc) != 0;
483  }
484 
491  bool getFloppyDiskFlag() const
492  {
493  return (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk) != 0;
494  }
495 
502  bool getFixedDiskFlag() const
503  {
504  return (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk) != 0;
505  }
506 
513  bool getRAMDiskFlag() const
514  {
515  return (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk) != 0;
516  }
517 
525  sal_uInt64 getTotalSpace() const
526  {
527  return _aInfo.uTotalSpace;
528  }
529 
537  sal_uInt64 getFreeSpace() const
538  {
539  return _aInfo.uFreeSpace;
540  }
541 
549  sal_uInt64 getUsedSpace() const
550  {
551  return _aInfo.uUsedSpace;
552  }
553 
561  sal_uInt32 getMaxNameLength() const
562  {
563  return _aInfo.uMaxNameLength;
564  }
565 
573  sal_uInt32 getMaxPathLength() const
574  {
575  return _aInfo.uMaxPathLength;
576  }
577 
586  {
588  }
589 
590 
599  {
600  return _aDevice;
601  }
602 
610  {
611  return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive) != 0;
612  }
613 
622  {
624  }
625 
626  friend class Directory;
627 };
628 
629 
630 class DirectoryItem;
631 
638 {
639  oslFileStatus _aStatus;
640  sal_uInt32 _nMask;
641 
646 
650  FileStatus& operator = ( FileStatus& ) SAL_DELETED_FUNCTION;
651 
652 public:
653 
654  enum Type {
663  };
664 
670  FileStatus(sal_uInt32 nMask)
671  : _nMask(nMask)
672  {
673  memset(&_aStatus, 0, sizeof(_aStatus));
674  _aStatus.uStructSize = sizeof(_aStatus);
675  }
676 
680  {
681  if ( _aStatus.ustrFileURL )
682  rtl_uString_release( _aStatus.ustrFileURL );
683  if ( _aStatus.ustrLinkTargetURL )
685  if ( _aStatus.ustrFileName )
686  rtl_uString_release( _aStatus.ustrFileName );
687  }
688 
698  bool isValid( sal_uInt32 nMask ) const
699  {
700  return ( nMask & _aStatus.uValidFields ) == nMask;
701  }
702 
709  {
710  SAL_INFO_IF(
711  !isValid(osl_FileStatus_Mask_Type), "sal.osl",
712  "no FileStatus Type determined");
714  ? static_cast< Type >(_aStatus.eType) : Unknown;
715  }
716 
726  bool isDirectory() const
727  {
728  return ( getFileType() == Directory || getFileType() == Volume );
729  }
730 
741  bool isRegular() const
742  {
743  return ( getFileType() == Regular );
744  }
745 
754  bool isLink() const
755  {
756  return ( getFileType() == Link );
757  }
758 
765  sal_uInt64 getAttributes() const
766  {
767  SAL_INFO_IF(
769  "no FileStatus Attributes determined");
770  return _aStatus.uAttributes;
771  }
772 
781  {
782  SAL_INFO_IF(
784  "no FileStatus CreationTime determined");
785  return _aStatus.aCreationTime;
786  }
787 
796  {
797  SAL_INFO_IF(
799  "no FileStatus AccessTime determined");
800  return _aStatus.aAccessTime;
801  }
802 
811  {
812  SAL_INFO_IF(
814  "no FileStatus ModifyTime determined");
815  return _aStatus.aModifyTime;
816  }
817 
824  sal_uInt64 getFileSize() const
825  {
826  SAL_INFO_IF(
828  "no FileStatus FileSize determined");
829  return _aStatus.uFileSize;
830  }
831 
839  {
840  SAL_INFO_IF(
842  "no FileStatus FileName determined");
844  ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
845  }
846 
847 
856  {
857  SAL_INFO_IF(
859  "no FileStatus FileURL determined");
861  ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
862  }
863 
872  {
873  SAL_INFO_IF(
875  "no FileStatus LinkTargetURL determined");
878  }
879 
880  friend class DirectoryItem;
881 };
882 
883 
890 class File: public FileBase
891 {
892  oslFileHandle _pData;
893  ::rtl::OUString _aPath;
894 
899 
903  File& operator = ( File& ) SAL_DELETED_FUNCTION;
904 
905 public:
906 
913  File( const ::rtl::OUString& ustrFileURL ): _pData( NULL ), _aPath( ustrFileURL ) {}
914 
919  {
920  close();
921  }
922 
930  rtl::OUString getURL() const { return _aPath; }
931 
974  RC open( sal_uInt32 uFlags )
975  {
976  return static_cast< RC >( osl_openFile( _aPath.pData, &_pData, uFlags ) );
977  }
978 
993  {
995 
996  if( _pData )
997  {
998  Error=osl_closeFile( _pData );
999  _pData = NULL;
1000  }
1001 
1002  return static_cast< RC >( Error );
1003  }
1004 
1021  SAL_WARN_UNUSED_RESULT RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
1022  {
1023  return static_cast< RC >( osl_setFilePos( _pData, uHow, uPos ) );
1024  }
1025 
1041  RC getPos( sal_uInt64& uPos )
1042  {
1043  return static_cast< RC >( osl_getFilePos( _pData, &uPos ) );
1044  }
1045 
1068  {
1069  return static_cast< RC >( osl_isEndOfFile( _pData, pIsEOF ) );
1070  }
1071 
1089  RC setSize( sal_uInt64 uSize )
1090  {
1091  return static_cast< RC >( osl_setFileSize( _pData, uSize ) );
1092  }
1093 
1113  RC getSize( sal_uInt64 &rSize )
1114  {
1115  return static_cast< RC >( osl_getFileSize( _pData, &rSize ) );
1116  }
1117 
1149  RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
1150  {
1151  return static_cast< RC >( osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ) );
1152  }
1153 
1187  RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
1188  {
1189  return static_cast< RC >( osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ) );
1190  }
1191 
1192 
1217  {
1218  return static_cast< RC >( osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) ) );
1219  }
1220 
1240  RC sync() const
1241  {
1242  SAL_WARN_IF(!_pData, "sal.osl", "File::sync(): File not open");
1243  return static_cast< RC >(osl_syncFile(_pData));
1244  }
1245 
1271  static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1272  {
1273  return static_cast< RC >( osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1274  }
1275 
1299  static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
1300  {
1301  return static_cast< RC >( osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData ) );
1302  }
1303 
1331  static RC replace(const ::rtl::OUString& ustrSourceFileURL,
1332  const ::rtl::OUString& ustrDestFileURL)
1333  {
1334  return static_cast<RC>(osl_replaceFile(ustrSourceFileURL.pData, ustrDestFileURL.pData));
1335  }
1336 
1363  static RC remove( const ::rtl::OUString& ustrFileURL )
1364  {
1365  return static_cast< RC >( osl_removeFile( ustrFileURL.pData ) );
1366  }
1367 
1383  static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
1384  {
1385  return static_cast< RC >( osl_setFileAttributes( ustrFileURL.pData, uAttributes ) );
1386  }
1387 
1409  static RC setTime(
1410  const ::rtl::OUString& ustrFileURL,
1411  const TimeValue& rCreationTime,
1412  const TimeValue& rLastAccessTime,
1413  const TimeValue& rLastWriteTime )
1414  {
1415  return static_cast< RC >( osl_setFileTime(
1416  ustrFileURL.pData,
1417  &rCreationTime,
1418  &rLastAccessTime,
1419  &rLastWriteTime ) );
1420  }
1421 
1422  friend class DirectoryItem;
1423 };
1424 
1425 
1432 {
1433  oslDirectoryItem _pData;
1434 
1435 public:
1436 
1440  DirectoryItem(): _pData( NULL )
1441  {
1442  }
1443 
1447  DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
1448  {
1449  if( _pData )
1450  osl_acquireDirectoryItem( _pData );
1451  }
1452 
1457  {
1458  if( _pData )
1459  osl_releaseDirectoryItem( _pData );
1460  }
1461 
1466  {
1467  if (&rItem != this)
1468  {
1469  if( _pData )
1470  osl_releaseDirectoryItem( _pData );
1471 
1472  _pData = rItem._pData;
1473 
1474  if( _pData )
1475  osl_acquireDirectoryItem( _pData );
1476  }
1477  return *this;
1478  }
1479 
1486  bool is()
1487  {
1488  return _pData != NULL;
1489  }
1490 
1524  static RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
1525  {
1526  if( rItem._pData)
1527  {
1528  osl_releaseDirectoryItem( rItem._pData );
1529  rItem._pData = NULL;
1530  }
1531 
1532  return static_cast< RC >( osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData ) );
1533  }
1534 
1567  {
1568  return static_cast< RC >( osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ) );
1569  }
1570 
1586  bool isIdenticalTo( const DirectoryItem &pOther )
1587  {
1588  return osl_identicalDirectoryItem( _pData, pOther._pData );
1589  }
1590 
1591  friend class Directory;
1592 };
1593 
1594 
1606 {
1607 public:
1609 
1619  virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
1620 };
1621 
1622 
1623 // This just an internal helper function for
1624 // private use.
1625 extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
1626 {
1627  static_cast<DirectoryCreationObserver*>(pData)->DirectoryCreated(aDirectoryUrl);
1628 }
1629 
1636 class Directory: public FileBase
1637 {
1638  oslDirectory _pData;
1639  ::rtl::OUString _aPath;
1640 
1645 
1649  Directory& operator = ( Directory& ) SAL_DELETED_FUNCTION;
1650 
1651 public:
1652 
1660  Directory( const ::rtl::OUString& strPath ): _pData( NULL ), _aPath( strPath )
1661  {
1662  }
1663 
1668  {
1669  close();
1670  }
1671 
1679  rtl::OUString getURL() const { return _aPath; }
1680 
1699  {
1700  return static_cast< RC >( osl_openDirectory( _aPath.pData, &_pData ) );
1701  }
1702 
1713  bool isOpen() { return _pData != NULL; }
1714 
1727  {
1728  oslFileError Error = osl_File_E_BADF;
1729 
1730  if( _pData )
1731  {
1732  Error=osl_closeDirectory( _pData );
1733  _pData = NULL;
1734  }
1735 
1736  return static_cast< RC >( Error );
1737  }
1738 
1739 
1757  {
1758  close();
1759  return open();
1760  }
1761 
1784  RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
1785  {
1786  if( rItem._pData )
1787  {
1788  osl_releaseDirectoryItem( rItem._pData );
1789  rItem._pData = NULL;
1790  }
1791  return static_cast<RC>(osl_getNextDirectoryItem( _pData, &rItem._pData, nHint ));
1792  }
1793 
1794 
1825  static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
1826  {
1827  return static_cast< RC >( osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask ) );
1828  }
1829 
1860  static RC create(
1861  const ::rtl::OUString& ustrDirectoryURL,
1862  sal_uInt32 flags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write )
1863  {
1864  return static_cast< RC >(
1865  osl_createDirectoryWithFlags( ustrDirectoryURL.pData, flags ) );
1866  }
1867 
1894  static RC remove( const ::rtl::OUString& ustrDirectoryURL )
1895  {
1896  return static_cast< RC >( osl_removeDirectory( ustrDirectoryURL.pData ) );
1897  }
1898 
1935  static RC createPath(
1936  const ::rtl::OUString& aDirectoryUrl,
1937  DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
1938  {
1939  return static_cast< RC >(osl_createDirectoryPath(
1940  aDirectoryUrl.pData,
1941  aDirectoryCreationObserver ? onDirectoryCreated : NULL,
1942  aDirectoryCreationObserver));
1943  }
1944 };
1945 
1946 } /* namespace osl */
1947 
1948 #endif // INCLUDED_OSL_FILE_HXX
1949 
1950 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VolumeInfo(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:428
Definition: file.h:103
Definition: file.h:329
Definition: file.h:111
TimeValue aCreationTime
First creation time in nanoseconds since 1/1/1970.
Definition: file.h:393
Definition: file.h:94
SAL_DLLPUBLIC oslFileError osl_releaseDirectoryItem(oslDirectoryItem Item)
Decrease the refcount of a directory item handle.
Definition: file.h:102
#define osl_FileStatus_Mask_ModifyTime
Definition: file.h:368
static RC getTempDirURL(::rtl::OUString &ustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
Definition: file.hxx:253
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:129
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:930
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:169
SAL_DLLPUBLIC sal_Bool osl_identicalDirectoryItem(oslDirectoryItem pItemA, oslDirectoryItem pItemB)
Determine if two directory items point the same underlying file.
resource busy
Definition: file.hxx:72
#define osl_Volume_Attribute_FloppyDisk
Definition: file.h:533
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...
function call was interrupted
Definition: file.hxx:61
FileStatus(sal_uInt32 nMask)
Constructor.
Definition: file.hxx:670
RC getNextItem(DirectoryItem &rItem, sal_uInt32 nHint=0)
Retrieve the next item of a previously opened directory.
Definition: file.hxx:1784
rtl_uString * ustrFileName
Case correct name of the file.
Definition: file.h:403
file exists where should only be created
Definition: file.hxx:73
Definition: file.h:334
Definition: file.hxx:656
device not ready
Definition: file.hxx:101
SAL_DLLPUBLIC oslFileError osl_syncFile(oslFileHandle Handle)
Synchronize the memory representation of a file with that on the physical medium. ...
struct _oslVolumeInfo oslVolumeInfo
Structure containing information about volumes.
remote resource is not directly available
Definition: file.hxx:98
no such file or directory
Definition: file.hxx:59
SAL_DLLPUBLIC oslFileError osl_createDirectoryPath(rtl_uString *aDirectoryUrl, oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, void *pData)
Create a directory path.
Type
Definition: file.hxx:654
Directory(const ::rtl::OUString &strPath)
Constructor.
Definition: file.hxx:1660
bad file descriptor
Definition: file.hxx:66
Definition: file.h:126
#define osl_Volume_Attribute_Case_Sensitive
Definition: file.h:536
RC getFileStatus(FileStatus &rStatus)
Retrieve information about a single file or directory.
Definition: file.hxx:1566
bool is()
Check for validity of this instance.
Definition: file.hxx:1486
file too large
Definition: file.hxx:82
Definition: file.h:99
improper link across file systems detected
Definition: file.hxx:74
sal_uInt64 getFileSize() const
Get the size of the file.
Definition: file.hxx:824
Type getFileType() const
Get the file type.
Definition: file.hxx:708
~VolumeInfo()
Definition: file.hxx:436
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.
RC readLine(::rtl::ByteSequence &aSeq)
Read a line from a file.
Definition: file.hxx:1216
RC open(sal_uInt32 uFlags)
Open a regular file.
Definition: file.hxx:974
oslFileError
Definition: file.h:89
range error (mathematical error)
Definition: file.hxx:89
Definition: condition.hxx:31
RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
Write a number of bytes to a file.
Definition: file.hxx:1187
sal_uInt32 uMaxNameLength
Maximum length of file name of a single item.
Definition: file.h:579
rtl_uString * ustrFileURL
Full URL of the file.
Definition: file.h:406
#define osl_FileStatus_Mask_Type
Definition: file.h:364
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:1299
file is a directory, invalid operation
Definition: file.hxx:77
TimeValue getCreationTime() const
Get the creation time of this file.
Definition: file.hxx:780
~VolumeDevice()
Destructor.
Definition: file.hxx:352
oslFileType eType
The type of the file (file, directory, volume).
Definition: file.h:388
SAL_DLLPUBLIC oslFileError osl_acquireVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Acquire a volume device handle.
oslVolumeDeviceHandle * pDeviceHandle
Pointer to handle the receives underlying device.
Definition: file.h:588
SAL_DLLPUBLIC oslFileError osl_getDirectoryItem(rtl_uString *pustrFileURL, oslDirectoryItem *pItem)
Retrieve a single directory item.
Definition: file.h:330
~DirectoryItem()
Destructor.
Definition: file.hxx:1456
#define osl_FileStatus_Mask_AccessTime
Definition: file.h:367
SAL_DLLPUBLIC oslFileError osl_getSystemPathFromFileURL(rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.h:134
static RC create(const ::rtl::OUString &ustrDirectoryURL, sal_uInt32 flags=osl_File_OpenFlag_Read|osl_File_OpenFlag_Write)
Create a directory.
Definition: file.hxx:1860
SAL_DLLPUBLIC oslFileError osl_searchFileURL(rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL)
Search a full qualified system path or a file URL.
Definition: file.h:117
Definition: file.hxx:660
#define osl_FileStatus_Mask_Attributes
Definition: file.h:365
rtl::OUString getURL() const
Obtain the URL.
Definition: file.hxx:1679
link has been severed
Definition: file.hxx:97
Definition: file.h:90
Definition: file.h:116
Definition: file.hxx:658
Main goals and usage hints.
Definition: file.hxx:662
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
RC close()
Close an open file.
Definition: file.hxx:992
sal_uInt64 getUsedSpace() const
Determine the used space of a volume device.
Definition: file.hxx:549
TimeValue getAccessTime() const
Get the file access time.
Definition: file.hxx:795
TimeValue aAccessTime
Last access time in nanoseconds since 1/1/1970.
Definition: file.h:396
VolumeDevice(const VolumeDevice &rDevice)
Copy constructor.
Definition: file.hxx:342
#define osl_File_OpenFlag_Write
Definition: file.h:635
SAL_DLLPUBLIC oslFileError osl_openFile(rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags)
Open a regular file.
SAL_DLLPUBLIC oslFileError osl_removeFile(rtl_uString *pustrFileURL)
Remove a regular file.
#define osl_Volume_Attribute_Remote
Definition: file.h:529
SAL_DLLPUBLIC oslFileError osl_getFileStatus(oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
Retrieve information about a single file or directory.
Definition: file.h:132
sal_uInt64 getAttributes() const
Get the file attributes.
Definition: file.hxx:765
Definition: file.hxx:661
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...
The VolumeInfo class.
Definition: file.hxx:405
bool getRemoveableFlag() const
Check the removable flag.
Definition: file.hxx:469
invalid argument to library function
Definition: file.hxx:78
Definition: file.h:105
sal_uInt64 uFreeSpace
Free space on the volume for the current process/user.
Definition: file.h:577
void * oslFileHandle
Definition: file.h:630
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_DLLPUBLIC oslFileError osl_readLine(oslFileHandle Handle, sal_Sequence **ppSequence)
Read a line from a file.
static RC replace(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Move a file to a new destination or rename it, taking old file&#39;s identity (if exists).
Definition: file.hxx:1331
SAL_DLLPUBLIC oslFileError osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.h:104
SAL_DLLPUBLIC oslFileError osl_getVolumeDeviceMountPath(oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL)
Get the full qualified URL where a device is mounted to.
Structure containing information about volumes.
Definition: file.h:564
SAL_DLLPUBLIC oslFileError osl_getVolumeInformation(rtl_uString *pustrDirectoryURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask)
Retrieve information about a volume.
function not implemented
Definition: file.hxx:93
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:698
SAL_DLLPUBLIC oslFileError osl_getFileURLFromSystemPath(rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.h:96
static RC getCanonicalName(const ::rtl::OUString &ustrRequestedURL, ::rtl::OUString &ustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.hxx:130
Definition: file.h:107
SAL_DLLPUBLIC oslFileError osl_getTempDirURL(rtl_uString **pustrTempDirURL)
Retrieves the file URL of the system&#39;s temporary directory path.
rtl_uString * ustrLinkTargetURL
Full URL of the target file if the file itself is a link.
Definition: file.h:410
SAL_DLLPUBLIC oslFileError osl_openDirectory(rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory)
Open a directory for enumerating its contents.
TimeValue getModifyTime() const
Get the file modification time.
Definition: file.hxx:810
bool isRegular() const
Is it a regular file?
Definition: file.hxx:741
static RC searchFileURL(const ::rtl::OUString &ustrFileName, const ::rtl::OUString &ustrSearchPath, ::rtl::OUString &ustrFileURL)
Search a full qualified system path or a file URL.
Definition: file.hxx:239
Definition: file.h:112
I/O error occurred.
Definition: file.hxx:62
SAL_WARN_UNUSED_RESULT SAL_DLLPUBLIC oslFileError osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos)
Set the internal position pointer of an open file.
virtual ~DirectoryCreationObserver()
Definition: file.hxx:1608
#define osl_Volume_Attribute_CompactDisc
Definition: file.h:530
Definition: file.h:110
The file class object provides access to file contents and attributes.
Definition: file.hxx:890
sal_uInt64 uUsedSpace
Used space on the volume for the current process/user.
Definition: file.h:575
Definition: file.h:332
Definition: file.h:127
::rtl::OUString getFileURL() const
Get the URL of the file.
Definition: file.hxx:855
Definition: file.h:131
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:569
static RC getSystemPathFromFileURL(const ::rtl::OUString &ustrFileURL, ::rtl::OUString &ustrSystemPath)
Convert a file URL into a system dependent path.
Definition: file.hxx:188
C++ class representing a SAL byte sequence.
Definition: byteseq.h:169
Definition: file.h:122
no space left on device, write failed
Definition: file.hxx:83
void * oslDirectory
Definition: file.h:143
Definition: file.h:120
Definition: file.h:137
too many links to file
Definition: file.hxx:86
Definition: file.h:114
unsigned char sal_Bool
Definition: types.h:38
domain error (mathematical error)
Definition: file.hxx:88
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:567
bool isValid(sal_uInt32 nMask) const
Check if specified fields are valid.
Definition: file.hxx:449
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC oslFileError osl_copyFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Copy a file to a new destination.
Definition: file.h:130
Definition: socket_decl.hxx:197
inappropriate I/O control operation
Definition: file.hxx:81
unmapped error: always last entry in enum!
Definition: file.hxx:102
void onDirectoryCreated(void *pData, rtl_uString *aDirectoryUrl)
Definition: file.hxx:1625
file permissions do not allow operation
Definition: file.hxx:70
no process matches the PID
Definition: file.hxx:60
void * oslDirectoryItem
Definition: file.h:144
RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
Read a number of bytes from a file.
Definition: file.hxx:1149
#define osl_FileStatus_Mask_CreationTime
Definition: file.h:366
#define osl_Volume_Attribute_RAMDisk
Definition: file.h:532
Definition: file.h:133
Definition: file.h:333
broken pipe; no process reading from other end of pipe
Definition: file.hxx:87
sal_uInt64 getTotalSpace() const
Determine the total space of a volume device.
Definition: file.hxx:525
invalid seek operation (such as on pipe)
Definition: file.hxx:84
Definition: file.h:100
#define SAL_WARN_IF(condition, area, stream)
Produce warning entry from stream in the given log area if condition is true.
Definition: log.hxx:373
VolumeDevice()
Constructor.
Definition: file.hxx:332
DirectoryItem & operator=(const DirectoryItem &rItem)
Assignment operator.
Definition: file.hxx:1465
no memory available
Definition: file.hxx:69
on success
Definition: file.hxx:57
rtl_uString * ustrFileSystemName
Points to a string that receives the name of the file system type.
Definition: file.h:585
Definition: bootstrap.hxx:33
Definition: file.h:91
Definition: file.h:98
~FileStatus()
Destructor.
Definition: file.hxx:679
bool isDirectory() const
Is it a directory? This method returns True for both directories, and volumes.
Definition: file.hxx:726
Definition: file.h:135
The VolumeDevice class.
Definition: file.hxx:323
Definition: file.hxx:104
bool getRAMDiskFlag() const
Check the RAM disk flag.
Definition: file.hxx:513
static RC setTime(const ::rtl::OUString &ustrFileURL, const TimeValue &rCreationTime, const TimeValue &rLastAccessTime, const TimeValue &rLastWriteTime)
Set the file time.
Definition: file.hxx:1409
SAL_DLLPUBLIC oslFileError osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.h:121
Structure containing information about files and directories.
Definition: file.h:382
SAL_DLLPUBLIC oslFileError osl_releaseVolumeDeviceHandle(oslVolumeDeviceHandle Handle)
Release a volume device handle.
sal_uInt32 uMaxPathLength
Maximum length of a full qualified path in system notation.
Definition: file.h:581
sal_uInt32 uAttributes
Attributes of the volume (remote and/or removable)
Definition: file.h:571
Definition: file.h:118
RC isEndOfFile(sal_Bool *pIsEOF)
Test if the end of a file is reached.
Definition: file.hxx:1067
#define osl_File_OpenFlag_Read
Definition: file.h:634
too many levels of symbolic links found during name lookup
Definition: file.hxx:95
SAL_DLLPUBLIC oslFileError osl_readFile(oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead)
Read a number of bytes from a file.
sal_uInt64 getFreeSpace() const
Determine the free space of a volume device.
Definition: file.hxx:537
Definition: file.h:336
RC getSize(sal_uInt64 &rSize)
Get the file size of an open file.
Definition: file.hxx:1113
sal_uInt32 getMaxNameLength() const
Determine the maximal length of a file name.
Definition: file.hxx:561
Definition: file.h:123
RC open()
Open a directory for enumerating its contents.
Definition: file.hxx:1698
sal_uInt32 uValidFields
Determines which members of the structure contain valid data.
Definition: file.h:386
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:305
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:171
Definition: file.h:124
filename too long
Definition: file.hxx:91
sal_uInt32 getMaxPathLength() const
Determine the maximal length of a path name.
Definition: file.hxx:573
SAL_DLLPUBLIC oslFileError osl_acquireDirectoryItem(oslDirectoryItem Item)
Increase the refcount of a directory item handle.
SAL_DLLPUBLIC oslFileError osl_getCanonicalName(rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL)
Determine a valid unused canonical name for a requested name.
Definition: file.h:331
VolumeDevice getDeviceHandle() const
Get the volume device handle.
Definition: file.hxx:598
process has too many distinct files open
Definition: file.hxx:80
Definition: file.h:101
~Directory()
Destructor.
Definition: file.hxx:1667
Definition: file.h:125
SAL_WARN_UNUSED_RESULT RC setPos(sal_uInt32 uHow, sal_Int64 uPos)
Set the internal position pointer of an open file.
Definition: file.hxx:1021
no such device or address
Definition: file.hxx:63
VolumeDevice & operator=(const VolumeDevice &rDevice)
Assignment operator.
Definition: file.hxx:364
sal_uInt64 uFileSize
Size in bytes of the file.
Definition: file.h:400
Base class for observers of directory creation notifications.
Definition: file.hxx:1605
value too large for defined data type
Definition: file.hxx:100
bool isOpen()
Query if directory is open.
Definition: file.hxx:1713
rtl::OUString getMountPath()
Get the full qualified URL where a device is mounted to.
Definition: file.hxx:384
SAL_DLLPUBLIC oslFileError osl_setFileTime(rtl_uString *pustrFileURL, const TimeValue *aCreationTime, const TimeValue *aLastAccessTime, const TimeValue *aLastWriteTime)
Set the file time.
static RC copy(const ::rtl::OUString &ustrSourceFileURL, const ::rtl::OUString &ustrDestFileURL)
Copy a file to a new destination.
Definition: file.hxx:1271
RC reset()
Resets the directory item enumeration to the beginning.
Definition: file.hxx:1756
RC close()
Close a directory.
Definition: file.hxx:1726
SAL_DLLPUBLIC oslFileError osl_closeDirectory(oslDirectory Directory)
Release a directory handle.
bool isCaseSensitiveFileSystem() const
Return whether the file system is case sensitive or case insensitive.
Definition: file.hxx:609
void * oslVolumeDeviceHandle
Definition: file.h:454
Time since Jan-01-1970.
Definition: time.h:76
The FileStatus class.
Definition: file.hxx:637
RC sync() const
Synchronize the memory representation of a file with that on the physical medium. ...
Definition: file.hxx:1240
RC
Definition: file.hxx:56
RC setSize(sal_uInt64 uSize)
Set the file size of an open file.
Definition: file.hxx:1089
Definition: file.h:119
Definition: file.h:113
Base class for all File System specific objects.
Definition: file.hxx:52
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be used.
Definition: types.h:288
Definition: file.h:128
#define SAL_INFO_IF(condition, area, stream)
Produce log entry from stream in the given log area if condition is true.
Definition: log.hxx:353
SAL_DLLPUBLIC oslFileError osl_setFileAttributes(rtl_uString *pustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
static RC createPath(const ::rtl::OUString &aDirectoryUrl, DirectoryCreationObserver *aDirectoryCreationObserver=NULL)
Create a directory path.
Definition: file.hxx:1935
SAL_DLLPUBLIC oslFileError osl_closeFile(oslFileHandle Handle)
Close an open file.
argument list too long
Definition: file.hxx:64
::rtl::OUString getLinkTargetURL() const
Get the link target URL.
Definition: file.hxx:871
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_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
Retrieve the next item of a previously opened directory.
sal_uInt64 uAttributes
File attributes.
Definition: file.h:390
Definition: file.h:97
#define osl_Volume_Attribute_Removeable
Definition: file.h:528
SAL_DLLPUBLIC oslFileError osl_createDirectoryWithFlags(rtl_uString *url, sal_uInt32 flags)
Create a directory, passing flags.
invalid or incomplete byte sequence of multibyte char found
Definition: file.hxx:96
Definition: file.h:335
Definition: file.h:106
socket operation timed out
Definition: file.hxx:103
there are no child processes
Definition: file.hxx:67
bool isLink() const
Is it a link?
Definition: file.hxx:754
illegal modification to read-only filesystem
Definition: file.hxx:85
Definition: file.h:95
The directory item class object provides access to file status information.
Definition: file.hxx:1431
no locks available
Definition: file.hxx:92
SAL_DLLPUBLIC oslFileError osl_replaceFile(rtl_uString *pustrSourceFileURL, rtl_uString *pustrDestFileURL)
Move a file to a new destination or rename it, taking old file&#39;s identity (if exists).
#define osl_FileStatus_Mask_FileSize
Definition: file.h:369
RC getPos(sal_uInt64 &uPos)
Retrieve the current position of the internal pointer of an open file.
Definition: file.hxx:1041
Definition: file.h:115
operation not permitted
Definition: file.hxx:58
resource temp unavailable, try again later
Definition: file.hxx:68
~File()
Destructor.
Definition: file.hxx:918
bool getRemoteFlag() const
Check the remote flag.
Definition: file.hxx:459
Definition: file.h:108
#define osl_FileStatus_Mask_FileName
Definition: file.h:370
bad address; an invalid pointer detected
Definition: file.hxx:71
DirectoryItem(const DirectoryItem &rItem)
Copy constructor.
Definition: file.hxx:1447
bool getCompactDiscFlag() const
Check the compact disc flag.
Definition: file.hxx:480
bool getFixedDiskFlag() const
Check the fixed disk flag.
Definition: file.hxx:502
#define osl_FileStatus_Mask_FileURL
Definition: file.h:371
static RC setAttributes(const ::rtl::OUString &ustrFileURL, sal_uInt64 uAttributes)
Set file attributes.
Definition: file.hxx:1383
Definition: file.hxx:657
too many distinct file openings
Definition: file.hxx:79
File(const ::rtl::OUString &ustrFileURL)
Constructor.
Definition: file.hxx:913
Definition: file.h:136
#define osl_Volume_Attribute_FixedDisk
Definition: file.h:531
DirectoryItem()
Constructor.
Definition: file.hxx:1440
deadlock avoided
Definition: file.hxx:90
SAL_DLLPUBLIC oslFileError osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize)
Get the file size of an open file.
file isn&#39;t a directory where one is needed
Definition: file.hxx:76
bool isIdenticalTo(const DirectoryItem &pOther)
Determine if a directory item point the same underlying file.
Definition: file.hxx:1586
sal_uInt64 uTotalSpace
Total available space on the volume for the current process/user.
Definition: file.h:573
TimeValue aModifyTime
Last modify time in nanoseconds since 1/1/1970.
Definition: file.h:398
The directory class object provides an enumeration of DirectoryItems.
Definition: file.hxx:1636
bool isCasePreservingFileSystem() const
Return whether the file system preserves the case of file and directory names or not.
Definition: file.hxx:621
bool getFloppyDiskFlag() const
Check the floppy disc flag.
Definition: file.hxx:491
static RC getVolumeInfo(const ::rtl::OUString &ustrDirectoryURL, VolumeInfo &rInfo)
Retrieve information about a volume.
Definition: file.hxx:1825
#define osl_Volume_Attribute_Case_Is_Preserved
Definition: file.h:535
Definition: file.h:92
::rtl::OUString getFileName() const
Get the file name.
Definition: file.hxx:838
::rtl::OUString getFileSystemName() const
Determine the name of the volume device&#39;s File System.
Definition: file.hxx:585
Definition: file.h:109
wrong device type specified
Definition: file.hxx:75
Definition: file.h:93
SAL_DLLPUBLIC oslFileError osl_removeDirectory(rtl_uString *pustrDirectoryURL)
Remove an empty directory.
sal_uInt32 uStructSize
Must be initialized with the size in bytes of the structure before passing it to any function...
Definition: file.h:384
directory not empty
Definition: file.hxx:94
file quote system is confused as there are too many users
Definition: file.hxx:99
invalid executable file format
Definition: file.hxx:65
#define osl_FileStatus_Mask_LinkTargetURL
Definition: file.h:372
static RC getFileURLFromSystemPath(const ::rtl::OUString &ustrSystemPath, ::rtl::OUString &ustrFileURL)
Convert a system dependent path into a file URL.
Definition: file.hxx:207