The CGUIFileSysWrap class provides an abstract way of accessing directories and files. More...
#include <GUIFileSysWrap.h>
Public Member Functions | |
CGUIFileSysWrap () | |
virtual | ~CGUIFileSysWrap () |
Destructor, frees the drives list. | |
virtual eC_Bool | CheckIfDirectoryExists (const eC_String &kPath) const =0 |
virtual eC_Bool | CheckIfFileExists (const eC_String &kPath) const =0 |
virtual eC_Bool | CheckIfFileOrDirectoryExists (const eC_String &kPath) const =0 |
virtual eC_Bool | CpFile (eC_String kSource, eC_String kDest, eC_Bool bOverwrite=false, eC_Bool bCopyEvenIfIdentical=true)=0 |
virtual eC_Bool | CreateRelativePath (const eC_String &kFromPath, const eC_String &kToPath, eC_String &kResultPath) const |
void | DeInit () |
virtual CGUIDirectory * | DirAlloc (const eC_String &kPath, const CGUIDirectory::StringList_t &kNameFilter, eC_UInt uiFilter=CGUIDirectory::ALL, CGUIDirectory::SortFlag_t eSort=CGUIDirectory::NAME, eC_Bool bCaseInsensitive=true) const =0 |
virtual CGUIDirectory * | DirAlloc (const eC_String &kPath="", const eC_String &kNameFilter="") const =0 |
eC_String | GetCurrentPath () const |
virtual const eC_String & | GetDirSeparator () const =0 |
virtual const CGUIDirInfo::DirInfoPtrList_t & | GetDrives ()=0 |
virtual eC_String | GetExecutablePath ()=0 |
eC_String | GetFileBaseName (const eC_String &rkFileName) const |
Extracts the base name of a file from a name that includes a path. More... | |
virtual time_t | GetFileDateTime (const eC_String &kPath) const |
eC_String | GetFileName (const eC_String &rkFileName) const |
Extracts the file name from a file name that includes a path. More... | |
virtual long | GetFileSize (const eC_String &kPath) const |
eC_String | GetFileSuffix (const eC_String &rkFileName) const |
Extracts the extension of a file name. More... | |
virtual eC_String | GetHomePath () const =0 |
eC_String | GetPath (const eC_String &rkFileName) const |
Extracts the path from a file name that includes a path. More... | |
const eC_String & | GetPOSIXDirSeparator () const |
virtual const eC_String & | GetRootPath () const =0 |
const eC_String & | GetWinDirSeparator () const |
virtual eC_Bool | IsDrive (const eC_String &kDirStr) const =0 |
virtual eC_Bool | IsStrAbsolute (const eC_String &kStr) const =0 |
eC_Bool | MakeAbsolutePath (const eC_String &kRelPath, eC_String &kAbsPath) const |
virtual eC_String | MakeDirectoryPath (const eC_String &kPath) const |
virtual eC_Bool | MakeNormalizedPlatformPath (const eC_String &kOrgPath, eC_String &kResultPath) const |
virtual eC_String | MakePlatformPath (const eC_String &kOrgPath) const =0 |
virtual eC_File * | OpenPlatformFile (const eC_String &kPath, eC_Flag uiMode=eC_File::FS_WRITEACCESS|eC_File::FS_READACCESS) const |
virtual eC_Bool | RemoveFile (const eC_String &kPath) const =0 |
void | SeparateString (const eC_String &kOrgStr, eC_String &kLeftStr, eC_String &kRightStr, const eC_String &kSeparator, eC_Bool bFromLeft) const |
virtual eC_Bool | SetCurrentPath (const eC_String &kPath)=0 |
Static Public Member Functions | |
static CGUIFileSysWrap & | GetInstance () |
Static Public Attributes | |
static const eC_String | ms_DirSepPOSIX |
Directory seperator used for *NIX file system. | |
static const eC_String | ms_DirSepWin |
Directory separator used for windows file system. | |
Protected Attributes | |
eC_String | m_kCurrentPath |
CGUIDirInfo::DirInfoPtrList_t | m_kDrivesList |
The CGUIFileSysWrap class provides an abstract way of accessing directories and files.
It is an abstract class. There are implementations for different operating systems. Use the GetInstance() static member function to obtain the platform-specific instance.
A starting point for working with directories is the method DirAlloc() which creates a CGUIDirectory instance. From this instance it is possible to access the contents of a directory. The instance must be deleted if it is not used anymore.
This class provides the possibility to get the general paths of the application and operating system. The GetCurrentPath() method gets the working directory of the current process. The home path is obtained by calling GetHomePath(). It is possible to get a list of drives of the operating system by calling the GetDrives() method. A method called IsDrive checks whether the given string stands for a drive or not.
Since the directory separators can differ between various operating systems, you can call GetDirSeparator() to get the directory separator for the operating system that Guiliani is currently running on. All paths used in the CGUIDirectory, CGUIDirInfo, CGUIFileSysWrap and their derived classes can be adapted to conform to the current operating system by calling the MakePlatformPath() method of this class.
There is a helper function called SeparateString() to split a string into two parts at a given separator. This method is used in separating the path and file name, or base name and suffix.
|
inline |
Constructor.
|
pure virtual |
Checks if a directory at given path exists.
kPath | Path to directory for which the existence should be checked. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Checks if a file at a given path exists.
kPath | Path to a file for which the existence should be checked. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Checks if a given path exists. The object specified might be a file or directory.
kPath | Path to a file or directory for which the existence should be checked. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Copy a file. All file data and file meta information are copied from the source file to the destination file.
If the given destination is a directory that differs from the source directory, the source file is copied to the destination. If the source and destination directories are the same, this method does nothing and returns False.
If the given destination is a file and it is the same file as the source file, this method does nothing and returns False. Otherwise, it checks whether the destination file exists. If the destination file does not exist, a new file is created. Otherwise it checks whether the destination file can be overwritten. If that is the case, the destination file is overwritten if specified.
kSource | The source file name including path. If it is a relative path, the current working directory of the file system wrapper is used to complete the path. |
kDest | The destination directory or file. If it is a relative path the current working directory of the file system wrapper is used to complete the path. |
bOverwrite | Pass true to overwrite the destination file if it already exists. |
bCopyEvenIfIdentical | True if we want to copy the files even if they already exist and are identical (modification date, modification time and size). False if we want to skip copying the files which already exists and have the same date,time of modification and size. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
virtual |
Create a relative path from one directory to another directory. Example: From: "C:\projects\GSE\my_streamruntime\bin" To: "C:\projects\TestPlatform\testdata" Result: "..\..\..\TestPlatform\testdata" The returned path does not contain a trailing directory separator.
kFromPath | The directory the result path will be relative to. |
kToPath | The destination directory. |
kResultPath | The resulting path. |
void CGUIFileSysWrap::DeInit | ( | ) |
Frees all internally allocated resources. Do not call this method from user code, it is called by Guiliani when shutting down.
|
pure virtual |
Allocate a CGUIDirectory instance by giving the path. The instance should be deleted after the user finishes using it.
kPath | The kPath for the directory that is passed as a parameter of the CGUIDirectory constructor. |
kNameFilter | The name filters to filter the directory that is passed as a parameter of the CGUIDirectory constructor. |
uiFilter | The filter attribute to filter the directory that is passed as a parameter of the CGUIDirectory constructor. |
eSort | The sort kind to sort the directory that is passed as a parameter of the CGUIDirectory constructor. |
bCaseInsensitive | The bool value to indicate whether sort the elements in the directory case-insensitive or not. This is also a parameter of the CGUIDirectory constructor. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Allocate a CGUIDirectory instance using the given path. The instance should be deleted after the user finishes using it.
kPath | The directory path; directly passed to the CGUIDirectory constructor. |
kNameFilter | The filter string; directly passed to the CGUIDirectory constructor. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
inline |
Returns the absolute path name of the current working directory.
|
pure virtual |
Gets the directory separator.
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Gets a list of the root directories on this system.
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Returns the absolute path to the current executable
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
eC_String CGUIFileSysWrap::GetFileBaseName | ( | const eC_String & | rkFileName | ) | const |
Extracts the base name of a file from a name that includes a path.
Example: path/subpath/filename.ext will become filename
rkFileName | The full file name to be examined. |
|
virtual |
Get the last time of modification of the file
kPath | Full filename (including path) of the file which is getting the last modification |
Reimplemented in CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
eC_String CGUIFileSysWrap::GetFileName | ( | const eC_String & | rkFileName | ) | const |
Extracts the file name from a file name that includes a path.
Example: path/subpath/filename.ext will become filename.ext
rkFileName | The full file name to be examined. |
|
virtual |
Get the size of the file
kPath | Full filename (including path) of the file which is getting the size |
Reimplemented in CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
eC_String CGUIFileSysWrap::GetFileSuffix | ( | const eC_String & | rkFileName | ) | const |
Extracts the extension of a file name.
Example: path/subpath/filename.ext.ext2 will become ext2
rkFileName | The full file name to be examined. |
|
pure virtual |
Get the current user's home path.
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
static |
return instance
eC_String CGUIFileSysWrap::GetPath | ( | const eC_String & | rkFileName | ) | const |
Extracts the path from a file name that includes a path.
rkFileName | The full file name to be examined. |
|
inline |
Returns the *NIX directory separator.
|
pure virtual |
Gets the absolute path for the root directory.
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
inline |
Returns the windows directory separator.
|
pure virtual |
Check whether the given directory string represents a drive or not.
kDirStr | The directory string to be checked. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
pure virtual |
Help function to check whether the given path string is an absolute path or not.
kStr | The given path. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
eC_Bool CGUIFileSysWrap::MakeAbsolutePath | ( | const eC_String & | kRelPath, |
eC_String & | kAbsPath | ||
) | const |
Converts a relative path to an absolute path using the current directory.
kRelPath | relative path |
kAbsPath | absolute path as return value |
|
virtual |
Adds a dir separator at the end of the given path, if there isn't already one.
kPath | Path to adjust. |
|
virtual |
Adjust the path with the correct path separator according to the operating system and remove all occurrences of "..". (i.e. "C:\projects\x\..\y\project" becomes "C:\projects\y\project"). After the path is adjusted, the returned path does not contain a trailing directory separator except when it is a root path (i.e. "/" or "C:\").
kOrgPath | The original path to be adjusted. |
kResultPath | The resulting path. |
|
pure virtual |
Adjust the path with the correct path separator according to the operating system. After the path is adjusted, the returned path does not contain a trailing directory separator except when it is a root path (i.e. "/" or "C:\").
kOrgPath | The original path to be adjusted. |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
virtual |
Opens the given file from the platform's filesystem. This method is useful for getting write-access to the filesystem. If you are looking for plain read-access and you wish to support Guiliani's Resource-File and Resource-Header feature, you should use the CGUIResourceFileHander and it's Open()-Interface instead.
kPath | Full filename (including path) of the file which shall be opened |
uiMode | Requested access mode (see eC_File for details) |
Reimplemented in CGUIFileSysWrapWin.
|
pure virtual |
Removes the file specified with the given absolute path name
kPath | Name of the file to be deleted |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
void CGUIFileSysWrap::SeparateString | ( | const eC_String & | kOrgStr, |
eC_String & | kLeftStr, | ||
eC_String & | kRightStr, | ||
const eC_String & | kSeparator, | ||
eC_Bool | bFromLeft | ||
) | const |
Help function used to split a string at a given separator. The result strings do not contain the separator. If the bFromLeft is true, it checks the first appearance of the separator from the beginning (left) of the string. If it is false, it checks the first appearance of the separator from end (right) of the string. If the separator character is not found, the kLeftStr result string takes the original one, and kRightStr is left empty.
kOrgStr | The original string that needs to be analyzed. |
kLeftStr | The left part of the result string. |
kRightStr | The right part of the result string. |
kSeparator | The separator character stored as a string. |
bFromLeft | Indicate whether the first appearance of the separator is searched from left or right (beginning or end) of kOrgStr. |
|
pure virtual |
Sets the application's current working directory to path. If the path is not an absolute path, it does not change the current working directory and returns False.
kPath | The path to set |
Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.
|
protected |
The current application path.
|
protected |
The list of drives in the system. It is initialized every time the user calls GetDrives.