LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/osl - file.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 173 203 85.2 %
Date: 2012-12-17 Functions: 68 79 86.1 %
Legend: Lines: hit not hit

          Line data    Source code
       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 _OSL_FILE_HXX_
      21             : #define _OSL_FILE_HXX_
      22             : 
      23             : #include "sal/config.h"
      24             : 
      25             : #include <string.h>
      26             : 
      27             : #include <cassert>
      28             : 
      29             : #include <osl/time.h>
      30             : #include <rtl/ustring.hxx>
      31             : 
      32             : #include <osl/file.h>
      33             : #include <rtl/byteseq.hxx>
      34             : 
      35             : #include <stdio.h>
      36             : 
      37             : namespace osl
      38             : {
      39             : 
      40             : 
      41             : // -----------------------------------------------------------------------------
      42             : /** Base class for all File System specific objects.
      43             : 
      44             :     @see Directory
      45             :     @see DirectoryItem
      46             :     @see File
      47             :  */
      48             : 
      49      628027 : class FileBase
      50             : {
      51             : public:
      52             : 
      53             :     enum RC {
      54             :         E_None         = osl_File_E_None,
      55             :         E_PERM         = osl_File_E_PERM,
      56             :         E_NOENT        = osl_File_E_NOENT,
      57             :         E_SRCH         = osl_File_E_SRCH,
      58             :         E_INTR         = osl_File_E_INTR,
      59             :         E_IO           = osl_File_E_IO,
      60             :         E_NXIO         = osl_File_E_NXIO,
      61             :         E_2BIG         = osl_File_E_2BIG,
      62             :         E_NOEXEC       = osl_File_E_NOEXEC,
      63             :         E_BADF         = osl_File_E_BADF,
      64             :         E_CHILD        = osl_File_E_CHILD,
      65             :         E_AGAIN        = osl_File_E_AGAIN,
      66             :         E_NOMEM        = osl_File_E_NOMEM,
      67             :         E_ACCES        = osl_File_E_ACCES,
      68             :         E_FAULT        = osl_File_E_FAULT,
      69             :         E_BUSY         = osl_File_E_BUSY,
      70             :         E_EXIST        = osl_File_E_EXIST,
      71             :         E_XDEV         = osl_File_E_XDEV,
      72             :         E_NODEV        = osl_File_E_NODEV,
      73             :         E_NOTDIR       = osl_File_E_NOTDIR,
      74             :         E_ISDIR        = osl_File_E_ISDIR,
      75             :         E_INVAL        = osl_File_E_INVAL,
      76             :         E_NFILE        = osl_File_E_NFILE,
      77             :         E_MFILE        = osl_File_E_MFILE,
      78             :         E_NOTTY        = osl_File_E_NOTTY,
      79             :         E_FBIG         = osl_File_E_FBIG,
      80             :         E_NOSPC        = osl_File_E_NOSPC,
      81             :         E_SPIPE        = osl_File_E_SPIPE,
      82             :         E_ROFS         = osl_File_E_ROFS,
      83             :         E_MLINK        = osl_File_E_MLINK,
      84             :         E_PIPE         = osl_File_E_PIPE,
      85             :         E_DOM          = osl_File_E_DOM,
      86             :         E_RANGE        = osl_File_E_RANGE,
      87             :         E_DEADLK       = osl_File_E_DEADLK,
      88             :         E_NAMETOOLONG  = osl_File_E_NAMETOOLONG,
      89             :         E_NOLCK        = osl_File_E_NOLCK,
      90             :         E_NOSYS        = osl_File_E_NOSYS,
      91             :         E_NOTEMPTY     = osl_File_E_NOTEMPTY,
      92             :         E_LOOP         = osl_File_E_LOOP,
      93             :         E_ILSEQ        = osl_File_E_ILSEQ,
      94             :         E_NOLINK       = osl_File_E_NOLINK,
      95             :         E_MULTIHOP     = osl_File_E_MULTIHOP,
      96             :         E_USERS        = osl_File_E_USERS,
      97             :         E_OVERFLOW     = osl_File_E_OVERFLOW,
      98             :         E_NOTREADY     = osl_File_E_NOTREADY,
      99             :         E_invalidError = osl_File_E_invalidError,   /* unmapped error: always last entry in enum! */
     100             :         E_TIMEDOUT     = osl_File_E_TIMEDOUT,
     101             :         E_NETWORK      = osl_File_E_NETWORK
     102             :     };
     103             : 
     104             : 
     105             : public:
     106             : 
     107             :     /** Determine a valid unused canonical name for a requested name.
     108             : 
     109             :         Determines a valid unused canonical name for a requested name.
     110             :         Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
     111             :         If a file or directory with the requested name already exists a new name is generated following
     112             :         the common rules on the actual Operating System and File System.
     113             : 
     114             :         @param ustrRequestedURL [in]
     115             :         Requested name of a file or directory.
     116             : 
     117             :         @param ustrValidURL [out]
     118             :         On success receives a name which is unused and valid on the actual Operating System and
     119             :         File System.
     120             : 
     121             :         @return
     122             :         E_None on success
     123             :         E_INVAL the format of the parameters was not valid
     124             : 
     125             :         @see DirectoryItem::getFileStatus()
     126             :     */
     127             : 
     128             :     static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
     129             :     {
     130             :         return (RC) osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData );
     131             :     }
     132             : 
     133             :     /** Convert a path relative to a given directory into an full qualified file URL.
     134             : 
     135             :         Convert a path relative to a given directory into an full qualified file URL.
     136             :         The function resolves symbolic links if possible and path ellipses, so on success
     137             :         the resulting absolute path is fully resolved.
     138             : 
     139             :         @param ustrBaseDirectoryURL [in]
     140             :         Base directory URL to which the relative path is related to.
     141             : 
     142             :         @param ustrRelativeFileURL [in]
     143             :         An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
     144             :         or an absolute path.
     145             :         If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
     146             : 
     147             :         @param ustrAbsoluteFileURL [out]
     148             :         On success it receives the full qualified absoulte file URL.
     149             : 
     150             :         @return
     151             :         E_None on success
     152             :         E_INVAL the format of the parameters was not valid
     153             :         E_NOMEM not enough memory for allocating structures
     154             :         E_NOTDIR not a directory
     155             :         E_ACCES permission denied
     156             :         E_NOENT no such file or directory
     157             :         E_NAMETOOLONG file name too long
     158             :         E_OVERFLOW value too large for defined data type
     159             :         E_FAULT bad address
     160             :         E_INTR function call was interrupted
     161             :         E_LOOP too many symbolic links encountered
     162             :         E_MULTIHOP multihop attempted
     163             :         E_NOLINK link has been severed
     164             : 
     165             :         @see DirectoryItem::getFileStatus()
     166             :     */
     167             : 
     168         350 :     static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
     169             :     {
     170         350 :         return (RC) osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData );
     171             :     }
     172             : 
     173             :     /** Convert a file URL into a system dependend path.
     174             : 
     175             :         @param ustrFileURL [in]
     176             :         A File URL.
     177             : 
     178             :         @param ustrSystemPath [out]
     179             :         On success it receives the system path.
     180             : 
     181             :         @return
     182             :         E_None on success
     183             :         E_INVAL the format of the parameters was not valid
     184             : 
     185             :         @see getFileURLFromSystemPath()
     186             :     */
     187             : 
     188      120960 :     static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
     189             :     {
     190      120960 :         return (RC) osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData );
     191             :     }
     192             : 
     193             :     /** Convert a system dependend path into a file URL.
     194             : 
     195             :         @param ustrSystemPath [in]
     196             :         A System dependent path of a file or directory.
     197             : 
     198             :         @param ustrFileURL [out]
     199             :         On success it receives the file URL.
     200             : 
     201             :         @return
     202             :         E_None on success
     203             :         E_INVAL the format of the parameters was not valid
     204             : 
     205             :         @see getSystemPathFromFileURL()
     206             :     */
     207             : 
     208       10046 :     static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
     209             :     {
     210       10046 :         return (RC) osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData );
     211             :     }
     212             : 
     213             :     /** Searche a full qualified system path or a file URL.
     214             : 
     215             :         @param ustrFileName [in]
     216             :         A system dependent path, a file URL, a file or relative directory
     217             : 
     218             :         @param ustrSearchPath [in]
     219             :         A list of system paths, in which a given file has to be searched. The Notation of a path list is
     220             :         system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
     221             :         These paths are only for the search of a file or a relative path, otherwise it will be ignored.
     222             :         If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
     223             :         a matching file in all system directories and in the directories listed in the PATH environment
     224             :         variable.
     225             :         The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
     226             :         aware of the Operating System and so doesn't know which path list delimiter to use.
     227             : 
     228             :         @param ustrFileURL [out]
     229             :         On success it receives the full qualified file URL.
     230             : 
     231             :         @return
     232             :         E_None on success
     233             :         E_INVAL the format of the parameters was not valid
     234             :         E_NOTDIR not a directory
     235             :         E_NOENT no such file or directory not found
     236             : 
     237             :         @see getFileURLFromSystemPath()
     238             :         @see getSystemPathFromFileURL()
     239             :     */
     240             : 
     241           0 :     static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
     242             :     {
     243           0 :         return (RC) osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData );
     244             :     }
     245             : 
     246             :     /** Retrieves the file URL of the system's temporary directory path.
     247             : 
     248             :         @param[out] ustrTempDirURL
     249             :         On success receives the URL of system's temporary directory path.
     250             : 
     251             :         @return
     252             :         E_None on success
     253             :         E_NOENT no such file or directory not found
     254             :     */
     255             : 
     256         134 :     static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
     257             :     {
     258         134 :         return (RC) osl_getTempDirURL( &ustrTempDirURL.pData );
     259             :     }
     260             : 
     261             :     /** Creates a temporary file in the directory provided by the caller or the
     262             :         directory returned by getTempDirURL.
     263             :         Under UNIX Operating Systems the file will be created with read and write
     264             :         access for the user exclusively.
     265             :         If the caller requests only a handle to the open file but not the name of
     266             :         it, the file will be automatically removed on close else the caller is
     267             :         responsible for removing the file on success.<br><br>
     268             : 
     269             :         @param  pustrDirectoryURL [in]
     270             :         Specifies the full qualified URL where the temporary file should be created.
     271             :         If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
     272             : 
     273             :         @param  pHandle [out]
     274             :         On success receives a handle to the open file.
     275             :         If pHandle is 0 the file will be closed on return, in this case
     276             :         pustrTempFileURL must not be 0.
     277             : 
     278             :         @param  pustrTempFileURL [out]
     279             :         On success receives the full qualified URL of the temporary file.
     280             :         If pustrTempFileURL is 0 the file will be automatically removed
     281             :         on close, in this case pHandle must not be 0.
     282             :         If pustrTempFileURL is not 0 the caller receives the name of the
     283             :         created file and is responsible for removing the file.
     284             : 
     285             :         @descr
     286             :         Description of the different pHandle, ppustrTempFileURL parameter combinations.
     287             :         pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
     288             :         pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
     289             :         will be returned on success and the file will be automatically removed on close<br>
     290             :         pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
     291             :         returned, the caller is responsible for opening, closing and removing the file.<br>
     292             :         pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
     293             :         the file name will be returned, the caller is responsible for closing and removing
     294             :         the file.<br>
     295             : 
     296             :         @return
     297             :         E_None   on success
     298             :         E_INVAL  the format of the parameter is invalid
     299             :         E_NOMEM  not enough memory for allocating structures
     300             :         E_ACCES  Permission denied
     301             :         E_NOENT  No such file or directory
     302             :         E_NOTDIR Not a directory
     303             :         E_ROFS   Read-only file system
     304             :         E_NOSPC  No space left on device
     305             :         E_DQUOT  Quota exceeded
     306             : 
     307             :         @see getTempDirURL()
     308             :     */
     309             : 
     310         275 :     static inline RC createTempFile(
     311             :         ::rtl::OUString* pustrDirectoryURL,
     312             :         oslFileHandle*   pHandle,
     313             :         ::rtl::OUString* pustrTempFileURL)
     314             :     {
     315         275 :         rtl_uString*  pustr_dir_url       = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
     316         275 :         rtl_uString** ppustr_tmp_file_url = pustrTempFileURL  ? &pustrTempFileURL->pData : 0;
     317             : 
     318         275 :         return (RC) osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url);
     319             :     }
     320             : };
     321             : 
     322             : 
     323             : // -----------------------------------------------------------------------------
     324             : /** The VolumeDevice class.
     325             : 
     326             :     @see VolumeInfo
     327             : */
     328             : 
     329             : class VolumeDevice : public FileBase
     330             : {
     331             :     oslVolumeDeviceHandle   _aHandle;
     332             : 
     333             : public:
     334             : 
     335             :     /** Constructor.
     336             :     */
     337             : 
     338        5172 :     VolumeDevice() : _aHandle( NULL )
     339             :     {
     340        5172 :     }
     341             : 
     342             :     /** Copy constructor.
     343             : 
     344             :         @param rDevice
     345             :         The other volume device.
     346             :     */
     347             : 
     348             :     VolumeDevice( const VolumeDevice & rDevice )
     349             :     {
     350             :         _aHandle = rDevice._aHandle;
     351             :         if ( _aHandle )
     352             :             osl_acquireVolumeDeviceHandle( _aHandle );
     353             :     }
     354             : 
     355             :     /** Destructor.
     356             :     */
     357             : 
     358        5172 :     ~VolumeDevice()
     359             :     {
     360        5172 :         if ( _aHandle )
     361           0 :             osl_releaseVolumeDeviceHandle( _aHandle );
     362        5172 :     }
     363             : 
     364             :     /** Assignment operator.
     365             : 
     366             :         @param rDevice
     367             :         The other volume device.
     368             :     */
     369             : 
     370             :     inline VolumeDevice & operator =( const VolumeDevice & rDevice )
     371             :     {
     372             :         oslVolumeDeviceHandle   newHandle = rDevice._aHandle;
     373             : 
     374             :         if ( newHandle )
     375             :             osl_acquireVolumeDeviceHandle( newHandle );
     376             : 
     377             :         if ( _aHandle )
     378             :             osl_releaseVolumeDeviceHandle( _aHandle );
     379             : 
     380             :         _aHandle = newHandle;
     381             : 
     382             :         return *this;
     383             :     }
     384             : 
     385             :     /** Get the full qualified URL where a device is mounted to.
     386             : 
     387             :            @return
     388             :         The full qualified URL where the device is mounted to.
     389             :     */
     390             :     inline rtl::OUString getMountPath()
     391             :     {
     392             :         rtl::OUString   aPath;
     393             :         osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
     394             :         return aPath;
     395             :     }
     396             : 
     397             :     friend class VolumeInfo;
     398             : };
     399             : 
     400             : // -----------------------------------------------------------------------------
     401             : 
     402             : class Directory;
     403             : 
     404             : /** The VolumeInfo class.
     405             : 
     406             :     Neither copy nor assignment is allowed for this class.
     407             : 
     408             :     @see Directory::getVolumeInfo
     409             : */
     410             : 
     411             : 
     412             : class VolumeInfo
     413             : {
     414             :     oslVolumeInfo   _aInfo;
     415             :     sal_uInt32      _nMask;
     416             :     VolumeDevice    _aDevice;
     417             : 
     418             :     /** Copy constructor.
     419             :     */
     420             : 
     421             :     VolumeInfo( VolumeInfo& );
     422             : 
     423             :     /** Assginment operator.
     424             :     */
     425             : 
     426             :     VolumeInfo& operator = ( VolumeInfo& );
     427             : 
     428             : public:
     429             : 
     430             :     /** Constructor.
     431             : 
     432             :         @param nMask
     433             :         Set of flags decribing the demanded information.
     434             :     */
     435             : 
     436        5172 :     VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
     437             :     {
     438        5172 :         _aInfo.uStructSize = sizeof( oslVolumeInfo );
     439        5172 :         memset( &_aInfo.uValidFields, 0, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ) );
     440        5172 :         _aInfo.pDeviceHandle = &_aDevice._aHandle;
     441        5172 :     }
     442             : 
     443             :     /** Destructor.
     444             :     */
     445             : 
     446        5172 :     ~VolumeInfo()
     447        5172 :     {
     448        5172 :         if( _aInfo.ustrFileSystemName )
     449           0 :             rtl_uString_release( _aInfo.ustrFileSystemName );
     450        5172 :     }
     451             : 
     452             :     /** Check if specified fields are valid.
     453             : 
     454             :         @param nMask
     455             :         Set of flags for the fields to check.
     456             : 
     457             :         @return sal_True if all fields are valid else sal_False.
     458             :     */
     459             : 
     460          16 :     inline sal_Bool isValid( sal_uInt32 nMask ) const
     461             :     {
     462          16 :         return ( nMask & _aInfo.uValidFields ) == nMask;
     463             :     }
     464             : 
     465             :     /** Check the remote flag.
     466             : 
     467             :         @return
     468             :         sal_True if Attributes are valid and the volume is remote else sal_False.
     469             :     */
     470             : 
     471           2 :     inline sal_Bool getRemoteFlag() const
     472             :     {
     473           2 :         return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
     474             :     }
     475             : 
     476             :     /** Check the removeable flag.
     477             : 
     478             :         @return
     479             :         sal_True if attributes are valid and the volume is removable else sal_False.
     480             :     */
     481             : 
     482           2 :     inline sal_Bool getRemoveableFlag() const
     483             :     {
     484           2 :         return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
     485             :     }
     486             : 
     487             :     /** Check the compact disc flag.
     488             : 
     489             :         @return
     490             :         sal_True if attributes are valid and the volume is a CDROM else sal_False.
     491             :     */
     492             : 
     493           2 :     inline sal_Bool getCompactDiscFlag() const
     494             :     {
     495           2 :         return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
     496             :     }
     497             : 
     498             :     /** Check the floppy disc flag.
     499             : 
     500             :         @return
     501             :         sal_True if attributes are valid and the volume is a floppy disk else sal_False.
     502             :     */
     503             : 
     504           2 :     inline sal_Bool getFloppyDiskFlag() const
     505             :     {
     506           2 :         return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
     507             :     }
     508             : 
     509             :     /** Check the fixed disk flag.
     510             : 
     511             :         @return
     512             :         sal_True if attributes are valid and the volume is a fixed disk else sal_False.
     513             :     */
     514             : 
     515           2 :     inline sal_Bool getFixedDiskFlag() const
     516             :     {
     517           2 :         return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
     518             :     }
     519             : 
     520             :     /** Check the RAM disk flag.
     521             : 
     522             :         @return
     523             :         sal_True if attributes are valid and the volume is a RAM disk else sal_False.
     524             :     */
     525             : 
     526           2 :     inline sal_Bool getRAMDiskFlag() const
     527             :     {
     528           2 :         return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
     529             :     }
     530             : 
     531             :     /** Determine the total space of a volume device.
     532             : 
     533             :         @return
     534             :         The total diskspace of this volume if this information is valid,
     535             :         0 otherwise.
     536             :     */
     537             : 
     538           2 :     inline sal_uInt64 getTotalSpace() const
     539             :     {
     540           2 :         return _aInfo.uTotalSpace;
     541             :     }
     542             : 
     543             :     /** Determine the free space of a volume device.
     544             : 
     545             :         @return
     546             :         The free diskspace of this volume if this information is valid,
     547             :         0 otherwise.
     548             :     */
     549             : 
     550           2 :     inline sal_uInt64 getFreeSpace() const
     551             :     {
     552           2 :         return _aInfo.uFreeSpace;
     553             :     }
     554             : 
     555             :     /** Determine the used space of a volume device.
     556             : 
     557             :         @return
     558             :         The used diskspace of this volume if this information is valid,
     559             :         0 otherwise.
     560             :     */
     561             : 
     562           2 :     inline sal_uInt64 getUsedSpace() const
     563             :     {
     564           2 :         return _aInfo.uUsedSpace;
     565             :     }
     566             : 
     567             :     /** Determine the maximal length of a file name.
     568             : 
     569             :         @return
     570             :         The maximal length of a file name if this information is valid,
     571             :         0 otherwise.
     572             :     */
     573             : 
     574           2 :     inline sal_uInt32 getMaxNameLength() const
     575             :     {
     576           2 :         return _aInfo.uMaxNameLength;
     577             :     }
     578             : 
     579             :     /** Determine the maximal length of a path name.
     580             : 
     581             :         @return
     582             :         The maximal length of a path if this information is valid,
     583             :         0 otherwise.
     584             :     */
     585             : 
     586           2 :     inline sal_uInt32 getMaxPathLength() const
     587             :     {
     588           2 :         return _aInfo.uMaxPathLength;
     589             :     }
     590             : 
     591             :     /** Determine the name of the volume device's File System.
     592             : 
     593             :         @return
     594             :         The name of the volume's fielsystem if this information is valid,
     595             :         otherwise an empty string.
     596             :     */
     597             : 
     598           0 :     inline ::rtl::OUString getFileSystemName() const
     599             :     {
     600           0 :         return _aInfo.ustrFileSystemName ? ::rtl::OUString( _aInfo.ustrFileSystemName ) : ::rtl::OUString();
     601             :     }
     602             : 
     603             : 
     604             :     /** Get the volume device handle.
     605             : 
     606             :         @return
     607             :         The device handle of the volume if this information is valid,
     608             :         otherwise returns NULL;
     609             :     */
     610             : 
     611             :     inline VolumeDevice getDeviceHandle() const
     612             :     {
     613             :         return _aDevice;
     614             :     }
     615             : 
     616             :     /** Return whether the file system is case sensitive or
     617             :         case insensitive
     618             : 
     619             :         @return
     620             :         true if the file system is case sensitive false otherwise
     621             :     */
     622           0 :     bool isCaseSensitiveFileSystem() const
     623             :     {
     624           0 :         return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive);
     625             :     }
     626             : 
     627             :     /** Return whether the file system preserves the case of
     628             :         file and directory names or not
     629             : 
     630             :         @return
     631             :         true if the file system preserves the case of file and
     632             :         directory names false otherwise
     633             :     */
     634             :     bool isCasePreservingFileSystem() const
     635             :     {
     636             :         return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Is_Preserved);
     637             :     }
     638             : 
     639             :     friend class Directory;
     640             : };
     641             : 
     642             : // -----------------------------------------------------------------------------
     643             : class DirectoryItem;
     644             : 
     645             : /** The FileStatus class.
     646             : 
     647             :     @see DirectoryItem::getFileStatus
     648             : */
     649             : 
     650             : class FileStatus
     651             : {
     652             :     oslFileStatus   _aStatus;
     653             :     sal_uInt32      _nMask;
     654             : 
     655             :     /** Copy constructor.
     656             :     */
     657             : 
     658             :     FileStatus( FileStatus& );
     659             : 
     660             :     /** Assignment operator.
     661             :     */
     662             : 
     663             :     FileStatus& operator = ( FileStatus& );
     664             : 
     665             : public:
     666             : 
     667             :     enum Type {
     668             :         Directory = osl_File_Type_Directory,
     669             :         Volume    = osl_File_Type_Volume,
     670             :         Regular   = osl_File_Type_Regular,
     671             :         Fifo      = osl_File_Type_Fifo,
     672             :         Socket    = osl_File_Type_Socket,
     673             :         Link      = osl_File_Type_Link,
     674             :         Special   = osl_File_Type_Special,
     675             :         Unknown   = osl_File_Type_Unknown
     676             :     };
     677             : 
     678             :     /** Constructor.
     679             : 
     680             :         @param nMask
     681             :         Set of flags decribing the demanded information.
     682             :     */
     683             : 
     684      582595 :     FileStatus( sal_uInt32 nMask ): _nMask( nMask )
     685             :     {
     686      582595 :         _aStatus.uStructSize = sizeof( oslFileStatus );
     687      582595 :         memset( &_aStatus.uValidFields, 0, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ) );
     688      582595 :     }
     689             : 
     690             :     /** Destructor.
     691             :     */
     692             : 
     693      582595 :     ~FileStatus()
     694             :     {
     695      582595 :         if ( _aStatus.ustrFileURL )
     696       77166 :             rtl_uString_release( _aStatus.ustrFileURL );
     697      582595 :         if ( _aStatus.ustrLinkTargetURL )
     698        8884 :             rtl_uString_release( _aStatus.ustrLinkTargetURL );
     699      582595 :         if ( _aStatus.ustrFileName )
     700       56044 :             rtl_uString_release( _aStatus.ustrFileName );
     701      582595 :     }
     702             : 
     703             :     /** Check if specified fields are valid.
     704             : 
     705             :         @param nMask
     706             :         Set of flags for the fields to check.
     707             : 
     708             :         @return
     709             :         sal_True if all fields are valid else sal_False.
     710             :     */
     711             : 
     712      341428 :     inline sal_Bool isValid( sal_uInt32 nMask ) const
     713             :     {
     714      341428 :         return ( nMask & _aStatus.uValidFields ) == nMask;
     715             :     }
     716             : 
     717             :     /** Get the file type.
     718             : 
     719             :         @return
     720             :         The file type.
     721             :     */
     722      118832 :     inline Type getFileType() const
     723             :     {
     724             :         SAL_INFO_IF(
     725             :             !isValid(osl_FileStatus_Mask_Type), "sal.osl",
     726             :             "no FileStatus Type determined");
     727      118832 :         return isValid(osl_FileStatus_Mask_Type)
     728      118832 :             ? static_cast< Type >(_aStatus.eType) : Unknown;
     729             :     }
     730             : 
     731             :     /** Is it a directory?
     732             :         This method returns True for both directories, and volumes.
     733             : 
     734             :         @return
     735             :         True if it's a directory, False otherwise.
     736             : 
     737             :         @see getFileType
     738             :         @since LibreOffice 3.6
     739             :     */
     740             :     inline sal_Bool isDirectory() const
     741             :     {
     742             :         return ( getFileType() == Directory || getFileType() == Volume );
     743             :     }
     744             : 
     745             :     /** Is it a regular file?
     746             : 
     747             :         @return
     748             :         True if it's a regular file, False otherwise.
     749             : 
     750             :         @see getFileType
     751             :         @see isFile
     752             :         @see isLink
     753             :         @since LibreOffice 3.6
     754             :     */
     755           4 :     inline sal_Bool isRegular() const
     756             :     {
     757           4 :         return ( getFileType() == Regular );
     758             :     }
     759             : 
     760             :     /** Is it a link?
     761             : 
     762             :         @return
     763             :         True if it's a link, False otherwise.
     764             : 
     765             :         @see getFileType
     766             :         @since LibreOffice 3.6
     767             :     */
     768             :     inline sal_Bool isLink() const
     769             :     {
     770             :         return ( getFileType() == Link );
     771             :     }
     772             : 
     773             :     /** Get the file attributes.
     774             : 
     775             :         @return
     776             :         The set of attribute flags of this file.
     777             :     */
     778             : 
     779       10885 :     inline sal_uInt64 getAttributes() const
     780             :     {
     781             :         SAL_INFO_IF(
     782             :             !isValid(osl_FileStatus_Mask_Attributes), "sal.osl",
     783             :             "no FileStatus Attributes determined");
     784       10885 :         return _aStatus.uAttributes;
     785             :     }
     786             : 
     787             :     /** Get the creation time of this file.
     788             : 
     789             :         @return
     790             :         The creation time if this information is valid, an uninitialized
     791             :         TimeValue otherwise.
     792             :     */
     793             : 
     794           0 :     inline TimeValue getCreationTime() const
     795             :     {
     796             :         SAL_INFO_IF(
     797             :             !isValid(osl_FileStatus_Mask_CreationTime), "sal.osl",
     798             :             "no FileStatus CreationTime determined");
     799           0 :         return _aStatus.aCreationTime;
     800             :     }
     801             : 
     802             :     /** Get the file access time.
     803             : 
     804             :         @return
     805             :         The last access time if this information is valid, an uninitialized
     806             :         TimeValue otherwise.
     807             :     */
     808             : 
     809           0 :     inline TimeValue getAccessTime() const
     810             :     {
     811             :         SAL_INFO_IF(
     812             :             !isValid(osl_FileStatus_Mask_AccessTime), "sal.osl",
     813             :             "no FileStatus AccessTime determined");
     814           0 :         return _aStatus.aAccessTime;
     815             :     }
     816             : 
     817             :     /** Get the file modification time.
     818             : 
     819             :         @return
     820             :         The last modified time if this information is valid, an uninitialized
     821             :         TimeValue otherwise.
     822             :     */
     823             : 
     824        5198 :     inline TimeValue getModifyTime() const
     825             :     {
     826             :         SAL_INFO_IF(
     827             :             !isValid(osl_FileStatus_Mask_ModifyTime), "sal.osl",
     828             :             "no FileStatus ModifyTime determined");
     829        5198 :         return _aStatus.aModifyTime;
     830             :     }
     831             : 
     832             :     /** Get the size of the file.
     833             : 
     834             :         @return
     835             :         The actual file size if this information is valid, 0 otherwise.
     836             :     */
     837             : 
     838        3178 :     inline sal_uInt64 getFileSize() const
     839             :     {
     840             :         SAL_INFO_IF(
     841             :             !isValid(osl_FileStatus_Mask_FileSize), "sal.osl",
     842             :             "no FileStatus FileSize determined");
     843        3178 :         return _aStatus.uFileSize;
     844             :     }
     845             : 
     846             :     /** Get the file name.
     847             : 
     848             :         @return
     849             :         The file name if this information is valid, an empty string otherwise.
     850             :     */
     851             : 
     852       53936 :     inline ::rtl::OUString getFileName() const
     853             :     {
     854             :         SAL_INFO_IF(
     855             :             !isValid(osl_FileStatus_Mask_FileName), "sal.osl",
     856             :             "no FileStatus FileName determined");
     857       53936 :         return isValid(osl_FileStatus_Mask_FileName)
     858       53936 :             ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
     859             :     }
     860             : 
     861             : 
     862             :     /** Get the URL of the file.
     863             : 
     864             :         @return
     865             :         The full qualified URL of the file if this information is valid, an
     866             :         empty string otherwise.
     867             :     */
     868             : 
     869       76262 :     inline ::rtl::OUString getFileURL() const
     870             :     {
     871             :         SAL_INFO_IF(
     872             :             !isValid(osl_FileStatus_Mask_FileURL), "sal.osl",
     873             :             "no FileStatus FileURL determined");
     874       76262 :         return isValid(osl_FileStatus_Mask_FileURL)
     875       76262 :             ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
     876             :     }
     877             : 
     878             :     /** Get the link target URL.
     879             : 
     880             :         @return
     881             :         The link target URL if this information is valid, an empty string
     882             :         otherwise.
     883             :     */
     884             : 
     885        8820 :     inline ::rtl::OUString getLinkTargetURL() const
     886             :     {
     887             :         SAL_INFO_IF(
     888             :             !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal.osl",
     889             :             "no FileStatus LinkTargetURL determined");
     890        8820 :         return isValid(osl_FileStatus_Mask_LinkTargetURL)
     891        8820 :             ? rtl::OUString(_aStatus.ustrLinkTargetURL) : rtl::OUString();
     892             :     }
     893             : 
     894             :     friend class DirectoryItem;
     895             : };
     896             : 
     897             : 
     898             : // -----------------------------------------------------------------------------
     899             : /** The file class object provides access to file contents and attributes.
     900             : 
     901             :     @see Directory
     902             :     @see DirectoryItem
     903             :  */
     904             : 
     905             : class File: public FileBase
     906             : {
     907             :     oslFileHandle   _pData;
     908             :     ::rtl::OUString _aPath;
     909             : 
     910             :     /** Copy constructor.
     911             :     */
     912             : 
     913             :     File( File& );
     914             : 
     915             :     /** Assginment operator.
     916             :     */
     917             : 
     918             :     File& operator = ( File& );
     919             : 
     920             : public:
     921             : 
     922             :     /** Constructor.
     923             : 
     924             :         @param  ustrFileURL [in]
     925             :         The full qualified URL of the file. Relative paths are not allowed.
     926             :     */
     927             : 
     928       12969 :     File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
     929             : 
     930             :     /** Destructor
     931             :     */
     932             : 
     933       12269 :     inline ~File()
     934       12269 :     {
     935       12269 :         close();
     936       12269 :     }
     937             : 
     938             :     /** Open a regular file.
     939             : 
     940             :         Open a file. Only regular files can be openend.
     941             : 
     942             :         @param uFlags [in]
     943             :         Specifies the open mode.
     944             : 
     945             :         @return
     946             :         E_None on success
     947             :         E_NOMEM not enough memory for allocating structures
     948             :         E_INVAL the format of the parameters was not valid
     949             :         E_NAMETOOLONG pathname was too long
     950             :         E_NOENT no such file or directory
     951             :         E_ACCES permission denied
     952             :         E_AGAIN a write lock could not be established
     953             :         E_NOTDIR not a directory
     954             :         E_NXIO no such device or address
     955             :         E_NODEV no such device
     956             :         E_ROFS read-only file system
     957             :         E_TXTBSY text file busy
     958             :         E_FAULT bad address
     959             :         E_LOOP too many symbolic links encountered
     960             :         E_NOSPC no space left on device
     961             :         E_ISDIR is a directory
     962             :         E_MFILE too many open files used by the process
     963             :         E_NFILE too many open files in the system
     964             :         E_DQUOT quota exceeded
     965             :         E_EXIST file exists
     966             :         E_INTR function call was interrupted
     967             :         E_IO on I/O errors
     968             :         E_MULTIHOP multihop attempted
     969             :         E_NOLINK link has been severed
     970             :         E_EOVERFLOW value too large for defined data type
     971             : 
     972             :         @see close()
     973             :         @see setPos()
     974             :         @see getPos()
     975             :         @see read()
     976             :         @see write()
     977             :         @see getSize()
     978             :         @see setSize()
     979             :     */
     980             : 
     981       13113 :     inline RC open( sal_uInt32 uFlags )
     982             :     {
     983       13113 :         return (RC) osl_openFile( _aPath.pData, &_pData, uFlags );
     984             :     }
     985             : 
     986             :     /** Close an open file.
     987             : 
     988             :         @return
     989             :         E_None on success
     990             :         E_INVAL the format of the parameters was not valid
     991             :         E_BADF Bad file
     992             :         E_INTR function call was interrupted
     993             :         E_NOLINK link has been severed
     994             :         E_NOSPC no space left on device
     995             :         E_IO on I/O errors
     996             : 
     997             :         @see open()
     998             :     */
     999             : 
    1000       29923 :     inline RC close()
    1001             :     {
    1002       29923 :         oslFileError Error = osl_File_E_BADF;
    1003             : 
    1004       29923 :         if( _pData )
    1005             :         {
    1006        9517 :             Error=osl_closeFile( _pData );
    1007        9517 :             _pData = NULL;
    1008             :         }
    1009             : 
    1010       29923 :         return (RC) Error;
    1011             :     }
    1012             : 
    1013             :     /** Set the internal position pointer of an open file.
    1014             : 
    1015             :         @param uHow [in]
    1016             :         Distance to move the internal position pointer (from uPos).
    1017             : 
    1018             :         @param uPos [in]
    1019             :         Absolute position from the beginning of the file.
    1020             : 
    1021             :         @return
    1022             :         E_None on success
    1023             :         E_INVAL the format of the parameters was not valid
    1024             :         E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
    1025             : 
    1026             :         @see open()
    1027             :         @see getPos()
    1028             :     */
    1029             : 
    1030       55674 :     inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos ) SAL_WARN_UNUSED_RESULT
    1031             :     {
    1032       55674 :         return (RC) osl_setFilePos( _pData, uHow, uPos );
    1033             :     }
    1034             : 
    1035             :     /** Retrieve the current position of the internal pointer of an open file.
    1036             : 
    1037             :         @param uPos [out]
    1038             :         On success receives the current position of the file pointer.
    1039             : 
    1040             :         @return
    1041             :         E_None on success
    1042             :         E_INVAL the format of the parameters was not valid
    1043             :         E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
    1044             : 
    1045             :         @see open()
    1046             :         @see setPos()
    1047             :         @see read()
    1048             :         @see write()
    1049             :     */
    1050             : 
    1051        3745 :     inline RC getPos( sal_uInt64& uPos )
    1052             :     {
    1053        3745 :         return (RC) osl_getFilePos( _pData, &uPos );
    1054             :     }
    1055             : 
    1056             :     /** Test if the end of a file is reached.
    1057             : 
    1058             :         @param pIsEOF [out]
    1059             :         Points to a variable that receives the end-of-file status.
    1060             : 
    1061             :         @return
    1062             :         E_None on success
    1063             :         E_INVAL the format of the parameters was not valid
    1064             :         E_INTR function call was interrupted
    1065             :         E_IO on I/O errors
    1066             :         E_ISDIR is a directory
    1067             :         E_BADF bad file
    1068             :         E_FAULT bad address
    1069             :         E_AGAIN operation would block
    1070             :         E_NOLINK link has been severed
    1071             : 
    1072             :         @see open()
    1073             :         @see read()
    1074             :         @see readLine()
    1075             :         @see setPos()
    1076             :     */
    1077             : 
    1078          10 :     inline RC isEndOfFile( sal_Bool *pIsEOF )
    1079             :     {
    1080          10 :         return (RC) osl_isEndOfFile( _pData, pIsEOF );
    1081             :     }
    1082             : 
    1083             :     /** Set the file size of an open file.
    1084             : 
    1085             :         Sets the file size of an open file. The file can be truncated or enlarged by the function.
    1086             :         The position of the file pointer is not affeced by this function.
    1087             : 
    1088             :         @param uSize [in]
    1089             :         New size in bytes.
    1090             : 
    1091             :         @return
    1092             :         E_None on success
    1093             :         E_INVAL the format of the parameters was not valid
    1094             :         E_OVERFLOW the resulting file offset would be a value which cannot  be represented correctly for regular files
    1095             : 
    1096             :         @see open()
    1097             :         @see setPos()
    1098             :         @see getStatus()
    1099             :     */
    1100             : 
    1101         128 :     inline RC setSize( sal_uInt64 uSize )
    1102             :     {
    1103         128 :         return (RC) osl_setFileSize( _pData, uSize );
    1104             :     }
    1105             : 
    1106             :     /** Get the file size of an open file.
    1107             : 
    1108             :         Gets the file size of an open file.
    1109             :         The position of the file pointer is not affeced by this function.
    1110             : 
    1111             :         @param rSize [out]
    1112             :         Current size in bytes.
    1113             : 
    1114             :         @return
    1115             :         E_None on success
    1116             :         E_INVAL the format of the parameters was not valid
    1117             :         E_OVERFLOW the resulting file offset would be a value which cannot  be represented correctly for regular files
    1118             : 
    1119             :         @see open()
    1120             :         @see setPos()
    1121             :         @see getSize()
    1122             :         @see setSize()
    1123             :         @see getStatus()
    1124             :     */
    1125             : 
    1126       18895 :     inline RC getSize( sal_uInt64 &rSize )
    1127             :     {
    1128       18895 :         return (RC) osl_getFileSize( _pData, &rSize );
    1129             :     }
    1130             : 
    1131             :     /** Read a number of bytes from a file.
    1132             : 
    1133             :         Reads a number of bytes from a file. The internal file pointer is
    1134             :         increased by the number of bytes read.
    1135             : 
    1136             :         @param pBuffer [out]
    1137             :         Points to a buffer which receives data. The buffer must be large enough
    1138             :         to hold uBytesRequested bytes.
    1139             : 
    1140             :         @param uBytesRequested [in]
    1141             :         Number of bytes which should be retrieved.
    1142             : 
    1143             :         @param rBytesRead [out]
    1144             :         On success the number of bytes which have actually been retrieved.
    1145             : 
    1146             :         @return
    1147             :         E_None on success
    1148             :         E_INVAL the format of the parameters was not valid
    1149             :         E_INTR function call was interrupted
    1150             :         E_IO on I/O errors
    1151             :         E_ISDIR is a directory
    1152             :         E_BADF bad file
    1153             :         E_FAULT bad address
    1154             :         E_AGAIN operation would block
    1155             :         E_NOLINK link has been severed
    1156             : 
    1157             :         @see open()
    1158             :         @see write()
    1159             :         @see readLine()
    1160             :         @see setPos()
    1161             :     */
    1162             : 
    1163       89313 :     inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
    1164             :     {
    1165       89313 :         return (RC) osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead );
    1166             :     }
    1167             : 
    1168             :     /** Write a number of bytes to a file.
    1169             : 
    1170             :         Writes a number of bytes to a file.
    1171             :         The internal file pointer is increased by the number of bytes read.
    1172             : 
    1173             :         @param pBuffer [in]
    1174             :         Points to a buffer which contains the data.
    1175             : 
    1176             :         @param uBytesToWrite [in]
    1177             :         Number of bytes which should be written.
    1178             : 
    1179             :         @param rBytesWritten [out]
    1180             :         On success the number of bytes which have actually been written.
    1181             : 
    1182             :         @return
    1183             :         E_None on success
    1184             :         E_INVAL the format of the parameters was not valid
    1185             :         E_FBIG file too large
    1186             :         E_DQUOT quota exceeded
    1187             :         E_AGAIN operation would block
    1188             :         E_BADF bad file
    1189             :         E_FAULT bad address
    1190             :         E_INTR function call was interrupted
    1191             :         E_IO on I/O errosr
    1192             :         E_NOLCK no record locks available
    1193             :         E_NOLINK link has been severed
    1194             :         E_NOSPC no space left on device
    1195             :         E_NXIO no such device or address
    1196             : 
    1197             :         @see open()
    1198             :         @see read()
    1199             :         @see setPos()
    1200             :     */
    1201             : 
    1202       13195 :     inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
    1203             :     {
    1204       13195 :         return (RC) osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten );
    1205             :     }
    1206             : 
    1207             : 
    1208             :     /** Read a line from a file.
    1209             : 
    1210             :         Reads a line from a file. The new line delimiter is NOT returned!
    1211             : 
    1212             :         @param  aSeq [in/out]
    1213             :         A reference to a ::rtl::ByteSequence that will hold the line read on success.
    1214             : 
    1215             :         @return
    1216             :         E_None on success
    1217             :         E_INVAL the format of the parameters was not valid
    1218             :         E_INTR function call was interrupted
    1219             :         E_IO on I/O errors
    1220             :         E_ISDIR is a directory
    1221             :         E_BADF bad file
    1222             :         E_FAULT bad address
    1223             :         E_AGAIN operation would block
    1224             :         E_NOLINK link has been severed
    1225             : 
    1226             :         @see open()
    1227             :         @see read()
    1228             :         @see write()
    1229             :         @see setPos()
    1230             :     */
    1231             : 
    1232          30 :     inline RC readLine( ::rtl::ByteSequence& aSeq )
    1233             :     {
    1234          30 :         return (RC) osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) );
    1235             :     }
    1236             : 
    1237             :     /** Synchronize the memory representation of a file with that on the physical medium.
    1238             : 
    1239             :     The function ensures that all modified data and attributes of the file associated with
    1240             :     the given file handle have been written to the physical medium.
    1241             :     In case the hard disk has a write cache enabled, the data may not really be on
    1242             :     permanent storage when osl_syncFile returns.
    1243             : 
    1244             :     @return
    1245             :     <dl>
    1246             :     <dt>E_None</dt>
    1247             :     <dd>On success</dd>
    1248             :     <dt>E_INVAL</dt>
    1249             :     <dd>The value of the input parameter is invalid</dd>
    1250             :     </dl>
    1251             :     <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
    1252             :     <dt>E_BADF</dt>
    1253             :     <dd>The file is not open for writing</dd>
    1254             :     <dt>E_IO</dt>
    1255             :     <dd>An I/O error occurred</dd>
    1256             :     <dt>E_NOSPC</dt>
    1257             :     <dd>There is no enough space on the target device</dd>
    1258             :     <dt>E_ROFS</dt>
    1259             :     <dd>The file is located on a read only file system</dd>
    1260             :     <dt>E_TIMEDOUT</dt>
    1261             :     <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
    1262             :     </dl>
    1263             : 
    1264             :     @see osl_syncFile()
    1265             :     @see open()
    1266             :     @see write()
    1267             :     */
    1268         134 :     inline RC sync() const
    1269             :     {
    1270             :         OSL_PRECOND(_pData, "File::sync(): File not open");
    1271         134 :         return (RC)osl_syncFile(_pData);
    1272             :     }
    1273             : 
    1274             :     /** Copy a file to a new destination.
    1275             : 
    1276             :         Copies a file to a new destination. Copies only files not directories.
    1277             :         No assumptions should be made about preserving attributes or file time.
    1278             : 
    1279             :         @param ustrSourceFileURL [in]
    1280             :         Full qualified URL of the source file.
    1281             : 
    1282             :         @param ustrDestFileURL [in]
    1283             :         Full qualified URL of the destination file. A directory is NOT a valid destination file!
    1284             : 
    1285             :         @return
    1286             :         E_None on success
    1287             :         E_INVAL the format of the parameters was not valid
    1288             :         E_NOMEM not enough memory for allocating structures
    1289             :         E_ACCES permission denied
    1290             :         E_PERM operation not permitted
    1291             :         E_NAMETOOLONG file name too long
    1292             :         E_NOENT no such file or directory
    1293             :         E_ISDIR is a directory
    1294             :         E_ROFS read-only file system
    1295             : 
    1296             :         @see move()
    1297             :         @see remove()
    1298             :     */
    1299             : 
    1300         709 :     inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
    1301             :     {
    1302         709 :         return (RC) osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
    1303             :     }
    1304             : 
    1305             :     /** Move a file or directory to a new destination or renames it.
    1306             : 
    1307             :         Moves a file or directory to a new destination or renames it.
    1308             :         File time and attributes are preserved.
    1309             : 
    1310             :         @param ustrSourceFileURL [in]
    1311             :         Full qualified URL of the source file.
    1312             : 
    1313             :         @param ustrDestFileURL [in]
    1314             :         Full qualified URL of the destination file. An existing directory is NOT a valid destination !
    1315             : 
    1316             :         @return
    1317             :         E_None on success
    1318             :         E_INVAL the format of the parameters was not valid
    1319             :         E_NOMEM not enough memory for allocating structures
    1320             :         E_ACCES permission denied
    1321             :         E_PERM operation not permitted
    1322             :         E_NAMETOOLONG file name too long
    1323             :         E_NOENT no such file or directory
    1324             :         E_ROFS read-only file system
    1325             : 
    1326             :         @see copy()
    1327             :     */
    1328             : 
    1329          27 :     inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
    1330             :     {
    1331          27 :         return (RC) osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
    1332             :     }
    1333             : 
    1334             :     /** Remove a regular file.
    1335             : 
    1336             :         @param ustrFileURL [in]
    1337             :         Full qualified URL of the file to remove.
    1338             : 
    1339             :         @return
    1340             :         E_None on success
    1341             :         E_INVAL the format of the parameters was not valid
    1342             :         E_NOMEM not enough memory for allocating structures
    1343             :         E_ACCES permission denied
    1344             :         E_PERM operation not permitted
    1345             :         E_NAMETOOLONG file name too long
    1346             :         E_NOENT no such file or directory
    1347             :         E_ISDIR is a directory
    1348             :         E_ROFS read-only file system
    1349             :         E_FAULT bad address
    1350             :         E_LOOP too many symbolic links encountered
    1351             :         E_IO on I/O errors
    1352             :         E_BUSY device or resource busy
    1353             :         E_INTR function call was interrupted
    1354             :         E_LOOP too many symbolic links encountered
    1355             :         E_MULTIHOP multihop attempted
    1356             :         E_NOLINK link has been severed
    1357             :         E_TXTBSY text file busy
    1358             : 
    1359             :         @see open()
    1360             :     */
    1361             : 
    1362        3994 :     inline static RC remove( const ::rtl::OUString& ustrFileURL )
    1363             :     {
    1364        3994 :         return (RC) osl_removeFile( ustrFileURL.pData );
    1365             :     }
    1366             : 
    1367             :     /** Set file attributes.
    1368             : 
    1369             :         @param ustrFileURL [in]
    1370             :         The full qualified file URL.
    1371             : 
    1372             :         @param uAttributes [in]
    1373             :         Attributes of the file to be set.
    1374             : 
    1375             :         @return
    1376             :         E_None on success
    1377             :         E_INVAL the format of the parameters was not valid
    1378             : 
    1379             :         @see FileStatus
    1380             :     */
    1381             : 
    1382         649 :     inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
    1383             :     {
    1384         649 :         return (RC) osl_setFileAttributes( ustrFileURL.pData, uAttributes );
    1385             :     }
    1386             : 
    1387             :     /** Set the file time.
    1388             : 
    1389             :         @param ustrFileURL [in]
    1390             :         The full qualified URL of the file.
    1391             : 
    1392             :         @param rCreationTime [in]
    1393             :         Creation time of the given file.
    1394             : 
    1395             :         @param rLastAccessTime [in]
    1396             :         Time of the last access of the given file.
    1397             : 
    1398             :         @param rLastWriteTime [in]
    1399             :         Time of the last modifying of the given file.
    1400             : 
    1401             :         @return
    1402             :         E_None on success
    1403             :         E_INVAL the format of the parameters was not valid
    1404             :         E_NOENT no such file or directory not found
    1405             : 
    1406             :         @see FileStatus
    1407             :     */
    1408             : 
    1409           0 :     inline static RC setTime(
    1410             :         const ::rtl::OUString& ustrFileURL,
    1411             :         const TimeValue& rCreationTime,
    1412             :         const TimeValue& rLastAccessTime,
    1413             :         const TimeValue& rLastWriteTime )
    1414             :     {
    1415             :         return (RC)  osl_setFileTime(
    1416             :             ustrFileURL.pData,
    1417             :             &rCreationTime,
    1418             :             &rLastAccessTime,
    1419           0 :             &rLastWriteTime );
    1420             :     }
    1421             : 
    1422             :     friend class DirectoryItem;
    1423             : };
    1424             : 
    1425             : // -----------------------------------------------------------------------------
    1426             : /** The directory item class object provides access to file status information.
    1427             : 
    1428             :     @see FileStatus
    1429             :  */
    1430             : 
    1431             : class DirectoryItem: public FileBase
    1432             : {
    1433             :     oslDirectoryItem _pData;
    1434             : 
    1435             : public:
    1436             : 
    1437             :     /** Constructor.
    1438             :     */
    1439             : 
    1440      585298 :     DirectoryItem(): _pData( NULL )
    1441             :     {
    1442      585298 :     }
    1443             : 
    1444             :     /** Copy constructor.
    1445             :     */
    1446             : 
    1447           0 :     DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
    1448             :     {
    1449           0 :         if( _pData )
    1450           0 :             osl_acquireDirectoryItem( _pData );
    1451           0 :     }
    1452             : 
    1453             :     /** Destructor.
    1454             :     */
    1455             : 
    1456      585298 :     ~DirectoryItem()
    1457             :     {
    1458      585298 :         if( _pData )
    1459       89421 :             osl_releaseDirectoryItem( _pData );
    1460      585298 :     }
    1461             : 
    1462             :     /** Assignment operator.
    1463             :     */
    1464             : 
    1465           0 :     DirectoryItem& operator=(const DirectoryItem& rItem )
    1466             :     {
    1467           0 :         if (&rItem != this)
    1468             :         {
    1469           0 :             if( _pData )
    1470           0 :                 osl_releaseDirectoryItem( _pData );
    1471             : 
    1472           0 :             _pData = rItem._pData;
    1473             : 
    1474           0 :             if( _pData )
    1475           0 :                 osl_acquireDirectoryItem( _pData );
    1476             :         }
    1477           0 :         return *this;
    1478             :     }
    1479             : 
    1480             :     /** Check for validity of this instance.
    1481             : 
    1482             :         @return
    1483             :         sal_True if object is valid directory item else sal_False.
    1484             :      */
    1485             : 
    1486           0 :     inline sal_Bool is()
    1487             :     {
    1488           0 :         return _pData != NULL;
    1489             :     }
    1490             : 
    1491             :     /** Retrieve a single directory item.
    1492             : 
    1493             :         Retrieves a single directory item. The returned handle has an initial refcount of 1.
    1494             :         Due to performance issues it is not recommended to use this function while
    1495             :         enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
    1496             : 
    1497             :         @param ustrFileURL [in]
    1498             :         An absolute file URL.
    1499             : 
    1500             :         @param rItem [out]
    1501             :         On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
    1502             :         The handle has to be released by a call to osl_releaseDirectoryItem().
    1503             : 
    1504             :         @return
    1505             :         E_None on success
    1506             :         E_INVAL the format of the parameters was not valid
    1507             :         E_NOMEM not enough memory for allocating structures
    1508             :         E_ACCES permission denied
    1509             :         E_MFILE too many open files used by the process
    1510             :         E_NFILE too many open files in the system
    1511             :         E_NOENT no such file or directory
    1512             :         E_LOOP  too many symbolic links encountered
    1513             :         E_NAMETOOLONG the file name is too long
    1514             :         E_NOTDIR a component of the path prefix of path is not a directory
    1515             :         E_IO on I/O errors
    1516             :         E_MULTIHOP multihop attempted
    1517             :         E_NOLINK link has been severed
    1518             :         E_FAULT bad address
    1519             :         E_INTR the function call was interrupted
    1520             : 
    1521             :         @see FileStatus
    1522             :         @see Directory::getNextItem()
    1523             :     */
    1524             : 
    1525      555511 :     static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
    1526             :     {
    1527      555511 :         if( rItem._pData)
    1528             :         {
    1529       11168 :             osl_releaseDirectoryItem( rItem._pData );
    1530       11168 :             rItem._pData = NULL;
    1531             :         }
    1532             : 
    1533      555511 :         return (RC) osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData );
    1534             :     }
    1535             : 
    1536             :     /** Retrieve information about a single file or directory.
    1537             : 
    1538             :         @param  rStatus [in|out]
    1539             :         Reference to a class which receives the information of the file or directory
    1540             :         represented by this directory item.
    1541             : 
    1542             :         @return
    1543             :         E_None on success
    1544             :         E_NOMEM not enough memory for allocating structures
    1545             :         E_INVAL the format of the parameters was not valid
    1546             :         E_LOOP too many symbolic links encountered
    1547             :         E_ACCES permission denied
    1548             :         E_NOENT no such file or directory
    1549             :         E_NAMETOOLONG file name too long
    1550             :         E_BADF invalid oslDirectoryItem parameter
    1551             :         E_FAULT bad address
    1552             :         E_OVERFLOW value too large for defined data type
    1553             :         E_INTR function call was interrupted
    1554             :         E_NOLINK link has been severed
    1555             :         E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
    1556             :         E_MFILE too many open files used by the process
    1557             :         E_NFILE too many open files in the system
    1558             :         E_NOSPC no space left on device
    1559             :         E_NXIO no such device or address
    1560             :         E_IO on I/O errors
    1561             :         E_NOSYS function not implemented
    1562             : 
    1563             :         @see get()
    1564             :         @see Directory::getNextItem()
    1565             :         @see FileStatus
    1566             :     */
    1567             : 
    1568      131226 :     inline RC getFileStatus( FileStatus& rStatus )
    1569             :     {
    1570      131226 :         return (RC) osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask );
    1571             :     }
    1572             : 
    1573             : /** Determine if a directory item point the the same underlying file
    1574             : 
    1575             :     The comparison is done first by URL, and then by resolving links to
    1576             :     find the target, and finally by comparing inodes on unix.
    1577             : 
    1578             :     @param[in]  pOther
    1579             :     A directory handle to compare with the underlying object's item
    1580             : 
    1581             :     @return
    1582             :     sal_True: if the items point to an identical resource<br>
    1583             :     sal_False: if the items point to a different resource, or a fatal error occured<br>
    1584             : 
    1585             :     @see osl_getDirectoryItem()
    1586             : 
    1587             :     @since LibreOffice 3.6
    1588             : */
    1589           0 :     inline sal_Bool isIdenticalTo( const DirectoryItem &pOther )
    1590             :     {
    1591           0 :         return osl_identicalDirectoryItem( _pData, pOther._pData );
    1592             :     }
    1593             : 
    1594             :     friend class Directory;
    1595             : };
    1596             : 
    1597             : //###########################################
    1598             : 
    1599             : /** Base class for observers of directory creation notifications.
    1600             : 
    1601             :     Clients which uses the method createDirectoryPath of the class
    1602             :     Directory may want to be informed about the directories that
    1603             :     have been created. This may be accomplished by deriving from
    1604             :     this base class and overwriting the virtual function
    1605             :     DirectoryCreated.
    1606             : 
    1607             :     @see Directory::createPath
    1608             : */
    1609           2 : class DirectoryCreationObserver
    1610             : {
    1611             : public:
    1612           2 :     virtual ~DirectoryCreationObserver() {}
    1613             : 
    1614             :     /** This method will be called when a new directory has been
    1615             :         created and needs to be overwritten by derived classes.
    1616             :         You must not delete the directory that was just created
    1617             :         otherwise you will run into an endless loop.
    1618             : 
    1619             :         @param aDirectoryUrl
    1620             :         [in]The absolute file URL of the directory that was just created by
    1621             :         ::osl::Directory::createPath.
    1622             :     */
    1623             :     virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
    1624             : };
    1625             : 
    1626             : //###########################################
    1627             : // This just an internal helper function for
    1628             : // private use.
    1629           4 : extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
    1630             : {
    1631           4 :     (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
    1632           4 : }
    1633             : 
    1634             : /** The directory class object provides a enumeration of DirectoryItems.
    1635             : 
    1636             :     @see DirectoryItem
    1637             :     @see File
    1638             :  */
    1639             : 
    1640             : class Directory: public FileBase
    1641             : {
    1642             :     oslDirectory    _pData;
    1643             :     ::rtl::OUString _aPath;
    1644             : 
    1645             :     /** Copy constructor.
    1646             :     */
    1647             : 
    1648             :     Directory( Directory& );
    1649             : 
    1650             :     /**  Assignment operator.
    1651             :     */
    1652             : 
    1653             :     Directory& operator = ( Directory& );
    1654             : 
    1655             : public:
    1656             : 
    1657             :     /** Constructor.
    1658             : 
    1659             :         @param strPath [in]
    1660             :         The full qualified URL of the directory.
    1661             :         Relative URLs are not allowed.
    1662             :      */
    1663             : 
    1664       24588 :     Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
    1665             :     {
    1666       24588 :     }
    1667             : 
    1668             :     /** Destructor.
    1669             :     */
    1670             : 
    1671       24588 :     ~Directory()
    1672       24588 :     {
    1673       24588 :         close();
    1674       24588 :     }
    1675             : 
    1676             :     /** Open a directory for enumerating its contents.
    1677             : 
    1678             :         @return
    1679             :         E_None on success
    1680             :         E_INVAL the format of the parameters was not valid
    1681             :         E_NOENT the specified path doesn't exist
    1682             :         E_NOTDIR the specified path is not an directory
    1683             :         E_NOMEM not enough memory for allocating structures
    1684             :         E_ACCES permission denied
    1685             :         E_MFILE too many open files used by the process
    1686             :         E_NFILE too many open files in the system
    1687             :         E_NAMETOOLONG File name too long
    1688             :         E_LOOP Too many symbolic links encountered
    1689             : 
    1690             :         @see getNextItem()
    1691             :         @see close()
    1692             :     */
    1693             : 
    1694       24544 :     inline RC open()
    1695             :     {
    1696       24544 :         return (RC) osl_openDirectory( _aPath.pData, &_pData );
    1697             :     }
    1698             : 
    1699             :     /** Query if directory is open.
    1700             : 
    1701             :         Query if directory is open and so item enumeration is valid.
    1702             : 
    1703             :         @return
    1704             :         sal_True if the directory is open else sal_False.
    1705             : 
    1706             :         @see open()
    1707             :         @see close()
    1708             :     */
    1709             : 
    1710          48 :     inline sal_Bool isOpen() { return _pData != NULL; }
    1711             : 
    1712             :     /** Close a directory.
    1713             : 
    1714             :          @return
    1715             :         E_None on success
    1716             :         E_INVAL the format of the parameters was not valid
    1717             :         E_NOMEM not enough memory for allocating structures
    1718             :         E_BADF invalid oslDirectory parameter
    1719             :         E_INTR the function call was interrupted
    1720             : 
    1721             :         @see open()
    1722             :     */
    1723             : 
    1724       38825 :     inline RC close()
    1725             :     {
    1726       38825 :         oslFileError Error = osl_File_E_BADF;
    1727             : 
    1728       38825 :         if( _pData )
    1729             :         {
    1730       16824 :             Error=osl_closeDirectory( _pData );
    1731       16824 :             _pData = NULL;
    1732             :         }
    1733             : 
    1734       38825 :         return (RC) Error;
    1735             :     }
    1736             : 
    1737             : 
    1738             :     /** Resets the directory item enumeration to the beginning.
    1739             : 
    1740             :         @return
    1741             :         E_None on success
    1742             :         E_INVAL the format of the parameters was not valid
    1743             :         E_NOENT the specified path doesn't exist
    1744             :         E_NOTDIR the specified path is not an directory
    1745             :         E_NOMEM not enough memory for allocating structures
    1746             :         E_ACCES permission denied
    1747             :         E_MFILE too many open files used by the process
    1748             :         E_NFILE too many open files in the system
    1749             :         E_NAMETOOLONG File name too long
    1750             :         E_LOOP Too many symbolic links encountered
    1751             : 
    1752             :         @see open()
    1753             :     */
    1754             : 
    1755         114 :     inline RC reset()
    1756             :     {
    1757         114 :         close();
    1758         114 :         return open();
    1759             :     }
    1760             : 
    1761             :     /** Retrieve the next item of a previously opened directory.
    1762             : 
    1763             :         Retrieves the next item of a previously opened directory.
    1764             : 
    1765             :         @param  rItem [out]
    1766             :         On success a valid DirectoryItem.
    1767             : 
    1768             :         @param  nHint [in]
    1769             :         With this parameter the caller can tell the implementation that (s)he
    1770             :         is going to call this function uHint times afterwards. This enables the implementation to
    1771             :         get the information for more than one file and cache it until the next calls.
    1772             : 
    1773             :         @return
    1774             :         E_None on success
    1775             :         E_INVAL the format of the parameters was not valid
    1776             :         E_NOMEM not enough memory for allocating structures
    1777             :         E_NOENT no more entries in this directory
    1778             :         E_BADF invalid oslDirectory parameter
    1779             :         E_OVERFLOW the value too large for defined data type
    1780             : 
    1781             :         @see DirectoryItem
    1782             :     */
    1783             : 
    1784       71405 :     inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
    1785             :     {
    1786       71405 :         if( rItem._pData )
    1787             :         {
    1788       33510 :             osl_releaseDirectoryItem( rItem._pData );
    1789       33510 :             rItem._pData = 0;
    1790             :         }
    1791       71405 :         return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
    1792             :     }
    1793             : 
    1794             : 
    1795             :     /** Retrieve information about a volume.
    1796             : 
    1797             :         Retrieves information about a volume. A volume can either be a mount point, a network
    1798             :         resource or a drive depending on Operating System and File System.
    1799             : 
    1800             :         @param ustrDirectoryURL [in]
    1801             :         Full qualified URL of the volume
    1802             : 
    1803             :         @param rInfo [out]
    1804             :         On success it receives information about the volume.
    1805             : 
    1806             :         @return
    1807             :         E_None on success
    1808             :         E_NOMEM not enough memory for allocating structures
    1809             :         E_INVAL the format of the parameters was not valid
    1810             :         E_NOTDIR not a directory
    1811             :         E_NAMETOOLONG file name too long
    1812             :         E_NOENT no such file or directory
    1813             :         E_ACCES permission denied
    1814             :         E_LOOP too many symbolic links encountered
    1815             :         E_FAULT Bad address
    1816             :         E_IO on I/O errors
    1817             :         E_NOSYS function not implemented
    1818             :         E_MULTIHOP multihop attempted
    1819             :         E_NOLINK link has been severed
    1820             :         E_INTR function call was interrupted
    1821             : 
    1822             :         @see FileStatus
    1823             :         @see VolumeInfo
    1824             :     */
    1825             : 
    1826          20 :     inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
    1827             :     {
    1828          20 :         return (RC) osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask );
    1829             :     }
    1830             : 
    1831             :     /** Create a directory.
    1832             : 
    1833             :         @param ustrDirectoryURL [in]
    1834             :         Full qualified URL of the directory to create.
    1835             : 
    1836             :         @return
    1837             :         E_None on success
    1838             :         E_INVAL the format of the parameters was not valid
    1839             :         E_NOMEM not enough memory for allocating structures
    1840             :         E_EXIST file exists
    1841             :         E_ACCES permission denied
    1842             :         E_NAMETOOLONG file name too long
    1843             :         E_NOENT no such file or directory
    1844             :         E_NOTDIR not a directory
    1845             :         E_ROFS read-only file system
    1846             :         E_NOSPC no space left on device
    1847             :         E_DQUOT quota exceeded
    1848             :         E_LOOP too many symbolic links encountered
    1849             :         E_FAULT bad address
    1850             :         E_IO on I/O errors
    1851             :         E_MLINK too many links
    1852             :         E_MULTIHOP multihop attempted
    1853             :         E_NOLINK link has been severed
    1854             : 
    1855             :         @see remove()
    1856             :     */
    1857             : 
    1858         119 :     inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
    1859             :     {
    1860         119 :         return (RC) osl_createDirectory( ustrDirectoryURL.pData );
    1861             :     }
    1862             : 
    1863             :     /** Remove an empty directory.
    1864             : 
    1865             :         @param ustrDirectoryURL [in]
    1866             :         Full qualified URL of the directory.
    1867             : 
    1868             :         @return
    1869             :         E_None on success
    1870             :         E_INVAL the format of the parameters was not valid
    1871             :         E_NOMEM not enough memory for allocating structures
    1872             :         E_PERM operation not permitted
    1873             :         E_ACCES permission denied
    1874             :         E_NOENT no such file or directory
    1875             :         E_NOTDIR not a directory
    1876             :         E_NOTEMPTY directory not empty
    1877             :         E_FAULT bad address
    1878             :         E_NAMETOOLONG file name too long
    1879             :         E_BUSY device or resource busy
    1880             :         E_ROFS read-only file system
    1881             :         E_LOOP too many symbolic links encountered
    1882             :         E_BUSY device or resource busy
    1883             :         E_EXIST file exists
    1884             :         E_IO on I/O errors
    1885             :         E_MULTIHOP multihop attempted
    1886             :         E_NOLINK link has been severed
    1887             : 
    1888             :         @see create()
    1889             :     */
    1890             : 
    1891          77 :     inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
    1892             :     {
    1893          77 :         return (RC) osl_removeDirectory( ustrDirectoryURL.pData );
    1894             :     }
    1895             : 
    1896             :     /** Create a directory path.
    1897             : 
    1898             :         The osl_createDirectoryPath function creates a specified directory path.
    1899             :         All nonexisting sub directories will be created.
    1900             :         <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
    1901             :         E_EXIST for existing directories. Programming against this error code is
    1902             :         in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
    1903             : 
    1904             :         @param aDirectoryUrl
    1905             :         [in] The absolute file URL of the directory path to create.
    1906             :         A relative file URL will not be accepted.
    1907             : 
    1908             :         @param aDirectoryCreationObserver
    1909             :         [in] Pointer to an instance of type DirectoryCreationObserver that will
    1910             :         be informed about the creation of a directory. The value of this
    1911             :         parameter may be NULL, in this case notifications will not be sent.
    1912             : 
    1913             :         @return
    1914             :         <dl>
    1915             :         <dt>E_None</dt>
    1916             :         <dd>On success</dd>
    1917             :         <dt>E_INVAL</dt>
    1918             :         <dd>The format of the parameters was not valid</dd>
    1919             :         <dt>E_ACCES</dt>
    1920             :         <dd>Permission denied</dd>
    1921             :         <dt>E_EXIST</dt>
    1922             :         <dd>The final node of the specified directory path already exist</dd>
    1923             :         <dt>E_NAMETOOLONG</dt>
    1924             :         <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
    1925             :         <dt>E_NOTDIR</dt>
    1926             :         <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
    1927             :         <dt>E_ROFS</dt>
    1928             :         <dd>Read-only file system</dd>
    1929             :         <dt>E_NOSPC</dt>
    1930             :         <dd>No space left on device</dd>
    1931             :         <dt>E_DQUOT</dt>
    1932             :         <dd>Quota exceeded</dd>
    1933             :         <dt>E_FAULT</dt>
    1934             :         <dd>Bad address</dd>
    1935             :         <dt>E_IO</dt>
    1936             :         <dd>I/O error</dd>
    1937             :         <dt>E_LOOP</dt>
    1938             :         <dd>Too many symbolic links encountered</dd>
    1939             :         <dt>E_NOLINK</dt>
    1940             :         <dd>Link has been severed</dd>
    1941             :         <dt>E_invalidError</dt>
    1942             :         <dd>An unknown error occurred</dd>
    1943             :         </dl>
    1944             : 
    1945             :         @see DirectoryCreationObserver
    1946             :         @see create
    1947             :     */
    1948          33 :     static RC createPath(
    1949             :         const ::rtl::OUString& aDirectoryUrl,
    1950             :         DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
    1951             :     {
    1952             :         return (RC)osl_createDirectoryPath(
    1953             :             aDirectoryUrl.pData,
    1954             :             (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
    1955          33 :             aDirectoryCreationObserver);
    1956             :     }
    1957             : };
    1958             : 
    1959             : } /* namespace osl */
    1960             : 
    1961             : #endif  /* _OSL_FILE_HXX_ */
    1962             : 
    1963             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10