diff options
author | Hennes Rohling <hro@openoffice.org> | 2000-11-13 10:52:19 +0000 |
---|---|---|
committer | Hennes Rohling <hro@openoffice.org> | 2000-11-13 10:52:19 +0000 |
commit | 2ff8765d5af795a4627e308e4975b9681a6034f3 (patch) | |
tree | 5d5c0d6d5d87959ee6ac103eb9460e283dd08565 /sal/inc/osl/file.hxx | |
parent | cd5ec36b10ff097863229563bfead1e4d5078a29 (diff) |
#76890# added VolumeInfo::getDeviceHandle
Diffstat (limited to 'sal/inc/osl/file.hxx')
-rw-r--r-- | sal/inc/osl/file.hxx | 558 |
1 files changed, 286 insertions, 272 deletions
diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx index 67fbd833e..9b571b9de 100644 --- a/sal/inc/osl/file.hxx +++ b/sal/inc/osl/file.hxx @@ -2,9 +2,9 @@ * * $RCSfile: file.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * last change: $Author: hro $ $Date: 2000-11-13 11:52:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,278 @@ namespace osl #endif +// ----------------------------------------------------------------------------- + +/** Base class for all filesystem specific objects + + @see Directory + @see DirectoryItem + @see File + */ + +class FileBase +{ +public: + + enum RC { + E_None = osl_File_E_None, + E_PERM = osl_File_E_PERM, + E_NOENT = osl_File_E_NOENT, + E_SRCH = osl_File_E_SRCH, + E_INTR = osl_File_E_INTR, + E_IO = osl_File_E_IO, + E_NXIO = osl_File_E_NXIO, + E_2BIG = osl_File_E_2BIG, + E_NOEXEC = osl_File_E_NOEXEC, + E_BADF = osl_File_E_BADF, + E_CHILD = osl_File_E_CHILD, + E_AGAIN = osl_File_E_AGAIN, + E_NOMEM = osl_File_E_NOMEM, + E_ACCES = osl_File_E_ACCES, + E_FAULT = osl_File_E_FAULT, + E_BUSY = osl_File_E_BUSY, + E_EXIST = osl_File_E_EXIST, + E_XDEV = osl_File_E_XDEV, + E_NODEV = osl_File_E_NODEV, + E_NOTDIR = osl_File_E_NOTDIR, + E_ISDIR = osl_File_E_ISDIR, + E_INVAL = osl_File_E_INVAL, + E_NFILE = osl_File_E_NFILE, + E_MFILE = osl_File_E_MFILE, + E_NOTTY = osl_File_E_NOTTY, + E_FBIG = osl_File_E_FBIG, + E_NOSPC = osl_File_E_NOSPC, + E_SPIPE = osl_File_E_SPIPE, + E_ROFS = osl_File_E_ROFS, + E_MLINK = osl_File_E_MLINK, + E_PIPE = osl_File_E_PIPE, + E_DOM = osl_File_E_DOM, + E_RANGE = osl_File_E_RANGE, + E_DEADLK = osl_File_E_DEADLK, + E_NAMETOOLONG = osl_File_E_NAMETOOLONG, + E_NOLCK = osl_File_E_NOLCK, + E_NOSYS = osl_File_E_NOSYS, + E_NOTEMPTY = osl_File_E_NOTEMPTY, + E_LOOP = osl_File_E_LOOP, + E_ILSEQ = osl_File_E_ILSEQ, + E_NOLINK = osl_File_E_NOLINK, + E_MULTIHOP = osl_File_E_MULTIHOP, + E_USERS = osl_File_E_USERS, + E_OVERFLOW = osl_File_E_OVERFLOW, + E_invalidError = osl_File_E_invalidError /* unmapped error: always last entry in enum! */ + }; + + +public: + + /** Determines a valid unused canonical name for a requested name. Depending on file system and operation system + the illegal characters are replaced by valid ones. If a file or directory with the requested name + already exists a new name is generated following the common rules on the actual file system and + operating system. + + @param strRequested [in] Requested name of a file or directory. + @param strValid [out] On success receives a name which is unused and valid on the actual operating system and + file system. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_getFileStatus + */ + + static inline RC getCanonicalName( const ::rtl::OUString& strRequested, ::rtl::OUString& strValid ) + { + return (RC) osl_getCanonicalName( strRequested.pData, &strValid.pData ); + } + + /** Converts a path relative to a given directory into an full qualified UNC path. + + @param strDirBase [in] Base directory to which the relative path is related to. + @param strRelative[in] Path of a file or directory relative to the directory path + specified by <code>strDirBase</code>. + @param strAbsolute [out] On success it receives the full qualified UNC path of the + requested relative path. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_NOTDIR Not a directory<br> + E_ACCES Permission denied<br> + E_NOENT No such file or directory<br> + E_NAMETOOLONG File name too long<p> + + + These errorcodes can (eventually) be returned:<p> + E_OVERFLOW Value too large for defined data type<p> + E_FAULT Bad address<br> + E_INTR function call was interrupted<br> + E_LOOP Too many symbolic links encountered<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<p> + + @see getStatus + */ + + static inline RC getAbsolutePath( const ::rtl::OUString& strDirBase, const ::rtl::OUString& strRelative, ::rtl::OUString& strAbsolute ) + { + return (RC) osl_getAbsolutePath( strDirBase.pData, strRelative.pData, &strAbsolute.pData ); + } + + /** Converts a system dependent path into a full qualified UNC path + + @param strSysPath[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see getCanonicalName + */ + + static inline RC normalizePath( const ::rtl::OUString& strSysPath, ::rtl::OUString& strPath ) + { + return (RC) osl_normalizePath( strSysPath.pData, &strPath.pData ); + } + + /** Converts a File URL into a full qualified UNC path + + @param urlPath[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see normalizePath + */ + + static inline RC getNormalizedPathFromFileURL( const ::rtl::OUString& strPath, ::rtl::OUString& normPath ) + { + return (RC) osl_getNormalizedPathFromFileURL( strPath.pData, &normPath.pData ); + } + + /** Converts a full qualified UNC path into a FileURL + + @param dir[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see normalizePath + @see getNormalizedPathFromFileURL + */ + + static inline RC getFileURLFromNormalizedPath( const ::rtl::OUString& normPath, ::rtl::OUString& strPath ) + { + return (RC) osl_getFileURLFromNormalizedPath( normPath.pData, &strPath.pData ); + } + + /** Converts a full qualified UNC path into a system depended path + + @param dir[in] Full qualified UNC path + @param strPath[out] On success it receives the System dependent path of a file or a directory + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see normalizePath + @see getNormalizedPathFromFileURL + */ + + static inline RC getSystemPathFromNormalizedPath( const ::rtl::OUString& normPath, ::rtl::OUString& strPath ) + { + return (RC)osl_getSystemPathFromNormalizedPath( normPath.pData, &strPath.pData ); + } + + /** Searches a full qualified UNC-Path/File + + @param filePath[in] System dependent path / Normalized Path / File-URL or file or relative directory + @param searchPath[in] Paths, in which a given file has to be searched. These paths are only for the search of a + file or a relative path, otherwise it will be ignored. If it is set to NULL or while using the + search path the search failed the function searches for a matching file in all system directories and in the directories + listed in the PATH environment variable + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOTDIR Not a directory<br> + E_NOENT No such file or directory not found<br> + @see normalizePath + */ + + static inline RC searchNormalizedPath( const ::rtl::OUString& filePath, const ::rtl::OUString& searchPath, ::rtl::OUString& strPath ) + { + return (RC) osl_searchNormalizedPath( filePath.pData, searchPath.pData, &strPath.pData ); + } +}; + +// ----------------------------------------------------------------------------- + +/** The VolumeDevice class + + @see VolumeInfo +*/ + +class VolumeDevice : public FileBase +{ + oslVolumeDeviceHandle _aHandle; + +public: + VolumeDevice() : _aHandle( NULL ) + { + } + + VolumeDevice( const VolumeDevice & rDevice ) + { + _aHandle = rDevice._aHandle; + if ( _aHandle ) + osl_acquireVolumeDeviceHandle( _aHandle ); + } + + ~VolumeDevice() + { + if ( _aHandle ) + osl_releaseVolumeDeviceHandle( _aHandle ); + } + + + inline VolumeDevice & operator =( const VolumeDevice & rDevice ) + { + oslVolumeDeviceHandle newHandle = rDevice._aHandle; + + if ( newHandle ) + osl_acquireVolumeDeviceHandle( _aHandle ); + + if ( _aHandle ) + osl_releaseVolumeDeviceHandle( _aHandle ); + + _aHandle = newHandle; + + return *this; + } + + inline RC automount() + { + return (RC)osl_automountVolumeDevice( _aHandle ); + } + + inline RC unmount() + { + return (RC)osl_unmountVolumeDevice( _aHandle ); + } + + inline rtl::OUString getMountPath() + { + rtl::OUString aPath; + osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData ); + return aPath; + } + + friend class VolumeInfo; +}; + +// ----------------------------------------------------------------------------- + /** The VolumeInfo class @see Directory::getVolumeInfo @@ -103,6 +375,7 @@ class VolumeInfo oslVolumeInfo _aInfo; sal_uInt32 _nMask; rtl_uString *_strFileSystemName; + VolumeDevice _aDevice; /** define copy c'tor and assginment operator privat */ @@ -123,6 +396,7 @@ public: rtl_fillMemory( &_aInfo.uValidFields, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ), 0 ); _strFileSystemName=NULL; _aInfo.pstrFileSystemName = &_strFileSystemName; + _aInfo.pDeviceHandle = &_aDevice._aHandle; } /** D'tor @@ -217,6 +491,16 @@ public: return _strFileSystemName; } + + /** @return the device handle of the volume if this information is valid, + otherwise returns NULL; + */ + + inline VolumeDevice getDeviceHandle() const + { + return _aDevice; + } + friend class Directory; }; @@ -400,276 +684,6 @@ public: // ----------------------------------------------------------------------------- -/** Base class for all filesystem specific objects - - @see Directory - @see DirectoryItem - @see File - */ - -class FileBase -{ -public: - - enum RC { - E_None = osl_File_E_None, - E_PERM = osl_File_E_PERM, - E_NOENT = osl_File_E_NOENT, - E_SRCH = osl_File_E_SRCH, - E_INTR = osl_File_E_INTR, - E_IO = osl_File_E_IO, - E_NXIO = osl_File_E_NXIO, - E_2BIG = osl_File_E_2BIG, - E_NOEXEC = osl_File_E_NOEXEC, - E_BADF = osl_File_E_BADF, - E_CHILD = osl_File_E_CHILD, - E_AGAIN = osl_File_E_AGAIN, - E_NOMEM = osl_File_E_NOMEM, - E_ACCES = osl_File_E_ACCES, - E_FAULT = osl_File_E_FAULT, - E_BUSY = osl_File_E_BUSY, - E_EXIST = osl_File_E_EXIST, - E_XDEV = osl_File_E_XDEV, - E_NODEV = osl_File_E_NODEV, - E_NOTDIR = osl_File_E_NOTDIR, - E_ISDIR = osl_File_E_ISDIR, - E_INVAL = osl_File_E_INVAL, - E_NFILE = osl_File_E_NFILE, - E_MFILE = osl_File_E_MFILE, - E_NOTTY = osl_File_E_NOTTY, - E_FBIG = osl_File_E_FBIG, - E_NOSPC = osl_File_E_NOSPC, - E_SPIPE = osl_File_E_SPIPE, - E_ROFS = osl_File_E_ROFS, - E_MLINK = osl_File_E_MLINK, - E_PIPE = osl_File_E_PIPE, - E_DOM = osl_File_E_DOM, - E_RANGE = osl_File_E_RANGE, - E_DEADLK = osl_File_E_DEADLK, - E_NAMETOOLONG = osl_File_E_NAMETOOLONG, - E_NOLCK = osl_File_E_NOLCK, - E_NOSYS = osl_File_E_NOSYS, - E_NOTEMPTY = osl_File_E_NOTEMPTY, - E_LOOP = osl_File_E_LOOP, - E_ILSEQ = osl_File_E_ILSEQ, - E_NOLINK = osl_File_E_NOLINK, - E_MULTIHOP = osl_File_E_MULTIHOP, - E_USERS = osl_File_E_USERS, - E_OVERFLOW = osl_File_E_OVERFLOW, - E_invalidError = osl_File_E_invalidError /* unmapped error: always last entry in enum! */ - }; - - -public: - - /** Determines a valid unused canonical name for a requested name. Depending on file system and operation system - the illegal characters are replaced by valid ones. If a file or directory with the requested name - already exists a new name is generated following the common rules on the actual file system and - operating system. - - @param strRequested [in] Requested name of a file or directory. - @param strValid [out] On success receives a name which is unused and valid on the actual operating system and - file system. - - @return osl_File_E_None on success otherwise one of the following errorcodes:<p> - osl_File_E_INVAL the format of the parameters was not valid<br> - - @see osl_getFileStatus - */ - - static inline RC getCanonicalName( const ::rtl::OUString& strRequested, ::rtl::OUString& strValid ) - { - return (RC) osl_getCanonicalName( strRequested.pData, &strValid.pData ); - } - - /** Converts a path relative to a given directory into an full qualified UNC path. - - @param strDirBase [in] Base directory to which the relative path is related to. - @param strRelative[in] Path of a file or directory relative to the directory path - specified by <code>strDirBase</code>. - @param strAbsolute [out] On success it receives the full qualified UNC path of the - requested relative path. - - @return E_None on success otherwise one of the following errorcodes:<p> - E_INVAL the format of the parameters was not valid<br> - E_NOMEM not enough memory for allocating structures <br> - E_NOTDIR Not a directory<br> - E_ACCES Permission denied<br> - E_NOENT No such file or directory<br> - E_NAMETOOLONG File name too long<p> - - - These errorcodes can (eventually) be returned:<p> - E_OVERFLOW Value too large for defined data type<p> - E_FAULT Bad address<br> - E_INTR function call was interrupted<br> - E_LOOP Too many symbolic links encountered<br> - E_MULTIHOP Multihop attempted<br> - E_NOLINK Link has been severed<p> - - @see getStatus - */ - - static inline RC getAbsolutePath( const ::rtl::OUString& strDirBase, const ::rtl::OUString& strRelative, ::rtl::OUString& strAbsolute ) - { - return (RC) osl_getAbsolutePath( strDirBase.pData, strRelative.pData, &strAbsolute.pData ); - } - - /** Converts a system dependent path into a full qualified UNC path - - @param strSysPath[in] System dependent path of a file or a directory - @param strPath[out] On success it receives the full qualified UNC path - - @return E_None on success otherwise one of the following errorcodes:<p> - E_INVAL the format of the parameters was not valid<br> - - @see getCanonicalName - */ - - static inline RC normalizePath( const ::rtl::OUString& strSysPath, ::rtl::OUString& strPath ) - { - return (RC) osl_normalizePath( strSysPath.pData, &strPath.pData ); - } - - /** Converts a File URL into a full qualified UNC path - - @param urlPath[in] System dependent path of a file or a directory - @param strPath[out] On success it receives the full qualified UNC path - - @return E_None on success otherwise one of the following errorcodes:<p> - E_INVAL the format of the parameters was not valid<br> - - @see normalizePath - */ - - static inline RC getNormalizedPathFromFileURL( const ::rtl::OUString& strPath, ::rtl::OUString& normPath ) - { - return (RC) osl_getNormalizedPathFromFileURL( strPath.pData, &normPath.pData ); - } - - /** Converts a full qualified UNC path into a FileURL - - @param dir[in] System dependent path of a file or a directory - @param strPath[out] On success it receives the full qualified UNC path - - @return E_None on success otherwise one of the following errorcodes:<p> - E_INVAL the format of the parameters was not valid<br> - - @see normalizePath - @see getNormalizedPathFromFileURL - */ - - static inline RC getFileURLFromNormalizedPath( const ::rtl::OUString& normPath, ::rtl::OUString& strPath ) - { - return (RC) osl_getFileURLFromNormalizedPath( normPath.pData, &strPath.pData ); - } - - /** Converts a full qualified UNC path into a system depended path - - @param dir[in] Full qualified UNC path - @param strPath[out] On success it receives the System dependent path of a file or a directory - - @return E_None on success otherwise one of the following errorcodes:<p> - E_INVAL the format of the parameters was not valid<br> - - @see normalizePath - @see getNormalizedPathFromFileURL - */ - - static inline RC getSystemPathFromNormalizedPath( const ::rtl::OUString& normPath, ::rtl::OUString& strPath ) - { - return (RC)osl_getSystemPathFromNormalizedPath( normPath.pData, &strPath.pData ); - } - - /** Searches a full qualified UNC-Path/File - - @param filePath[in] System dependent path / Normalized Path / File-URL or file or relative directory - @param searchPath[in] Paths, in which a given file has to be searched. These paths are only for the search of a - file or a relative path, otherwise it will be ignored. If it is set to NULL or while using the - search path the search failed the function searches for a matching file in all system directories and in the directories - listed in the PATH environment variable - @param strPath[out] On success it receives the full qualified UNC path - - @return E_None on success otherwise one of the following errorcodes:<p> - E_INVAL the format of the parameters was not valid<br> - E_NOTDIR Not a directory<br> - E_NOENT No such file or directory not found<br> - @see normalizePath - */ - - static inline RC searchNormalizedPath( const ::rtl::OUString& filePath, const ::rtl::OUString& searchPath, ::rtl::OUString& strPath ) - { - return (RC) osl_searchNormalizedPath( filePath.pData, searchPath.pData, &strPath.pData ); - } -}; - -// ----------------------------------------------------------------------------- - -/** The VolumeDevice class - - @see VolumeInfo -*/ - -class VolumeDevice : public FileBase -{ - oslVolumeDeviceHandle _aHandle; - -public: - VolumeDevice() : _aHandle( NULL ) - { - } - - VolumeDevice( const VolumeDevice & rDevice ) - { - _aHandle = rDevice._aHandle; - if ( _aHandle ) - osl_acquireVolumeDeviceHandle( _aHandle ); - } - - ~VolumeDevice() - { - if ( _aHandle ) - osl_releaseVolumeDeviceHandle( _aHandle ); - } - - - inline VolumeDevice & operator =( const VolumeDevice & rDevice ) - { - oslVolumeDeviceHandle newHandle = rDevice._aHandle; - - if ( newHandle ) - osl_acquireVolumeDeviceHandle( _aHandle ); - - if ( _aHandle ) - osl_releaseVolumeDeviceHandle( _aHandle ); - - _aHandle = newHandle; - - return *this; - } - - inline RC automount() - { - return (RC)osl_automountVolumeDevice( _aHandle ); - } - - inline RC unmount() - { - return (RC)osl_unmountVolumeDevice( _aHandle ); - } - - inline rtl::OUString getMountPath() - { - rtl::OUString aPath; - osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData ); - return aPath; - } - - friend class VolumeInfo; -}; - -// ----------------------------------------------------------------------------- - /** The file class object provides access to file contents and attributes @see Directory |