Guiliani  Version 2.6 revision 7293 (documentation build 12)
CGUIFileSysWrap Class Referenceabstract

The CGUIFileSysWrap class provides an abstract way of accessing directories and files. More...

#include <GUIFileSysWrap.h>

Inheritance diagram for CGUIFileSysWrap:

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 CGUIDirectoryDirAlloc (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 CGUIDirectoryDirAlloc (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_tGetDrives ()=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 CGUIFileSysWrapGetInstance ()
 

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CGUIFileSysWrap()

CGUIFileSysWrap::CGUIFileSysWrap ( )
inline

Constructor.

Member Function Documentation

◆ CheckIfDirectoryExists()

virtual eC_Bool CGUIFileSysWrap::CheckIfDirectoryExists ( const eC_String &  kPath) const
pure virtual

Checks if a directory at given path exists.

Parameters
kPathPath to directory for which the existence should be checked.
Returns
True If the directory specified via the path exists or False if its not a directory (for example file).

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ CheckIfFileExists()

virtual eC_Bool CGUIFileSysWrap::CheckIfFileExists ( const eC_String &  kPath) const
pure virtual

Checks if a file at a given path exists.

Parameters
kPathPath to a file for which the existence should be checked.
Returns
True If the file specified via the path exists or False if it is not a file (for example a directory) or a symlink.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ CheckIfFileOrDirectoryExists()

virtual eC_Bool CGUIFileSysWrap::CheckIfFileOrDirectoryExists ( const eC_String &  kPath) const
pure virtual

Checks if a given path exists. The object specified might be a file or directory.

Parameters
kPathPath to a file or directory for which the existence should be checked.
Returns
True If the object specified via the path exists otherwise False.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ CpFile()

virtual eC_Bool CGUIFileSysWrap::CpFile ( eC_String  kSource,
eC_String  kDest,
eC_Bool  bOverwrite = false,
eC_Bool  bCopyEvenIfIdentical = true 
)
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.

Parameters
kSourceThe 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.
kDestThe 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.
bOverwritePass true to overwrite the destination file if it already exists.
bCopyEvenIfIdenticalTrue 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.
Returns
True if successful, otherwise False.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ CreateRelativePath()

virtual eC_Bool CGUIFileSysWrap::CreateRelativePath ( const eC_String &  kFromPath,
const eC_String &  kToPath,
eC_String &  kResultPath 
) const
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.

Parameters
kFromPathThe directory the result path will be relative to.
kToPathThe destination directory.
kResultPathThe resulting path.
Returns
True if successful, False otherwise (i.e. if "From" and "To" path are on different drives).

◆ DeInit()

void CGUIFileSysWrap::DeInit ( )

Frees all internally allocated resources. Do not call this method from user code, it is called by Guiliani when shutting down.

◆ DirAlloc() [1/2]

virtual CGUIDirectory * CGUIFileSysWrap::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
pure virtual

Allocate a CGUIDirectory instance by giving the path. The instance should be deleted after the user finishes using it.

Parameters
kPathThe kPath for the directory that is passed as a parameter of the CGUIDirectory constructor.
kNameFilterThe name filters to filter the directory that is passed as a parameter of the CGUIDirectory constructor.
uiFilterThe filter attribute to filter the directory that is passed as a parameter of the CGUIDirectory constructor.
eSortThe sort kind to sort the directory that is passed as a parameter of the CGUIDirectory constructor.
bCaseInsensitiveThe bool value to indicate whether sort the elements in the directory case-insensitive or not. This is also a parameter of the CGUIDirectory constructor.
Returns
Pointer to the allocated CGUIDirectory instance.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ DirAlloc() [2/2]

virtual CGUIDirectory * CGUIFileSysWrap::DirAlloc ( const eC_String &  kPath = "",
const eC_String &  kNameFilter = "" 
) const
pure virtual

Allocate a CGUIDirectory instance using the given path. The instance should be deleted after the user finishes using it.

Parameters
kPathThe directory path; directly passed to the CGUIDirectory constructor.
kNameFilterThe filter string; directly passed to the CGUIDirectory constructor.
Returns
Pointer to the allocated CGUIDirectory instance.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetCurrentPath()

eC_String CGUIFileSysWrap::GetCurrentPath ( ) const
inline

Returns the absolute path name of the current working directory.

Note
Under Windows CE there is no concept of a "current working directory". Only the directory where the application was started from can be returned.
Returns
The absolute path of the application's current directory.

◆ GetDirSeparator()

virtual const eC_String & CGUIFileSysWrap::GetDirSeparator ( ) const
pure virtual

Gets the directory separator.

Returns
The directory separator.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetDrives()

virtual const CGUIDirInfo::DirInfoPtrList_t & CGUIFileSysWrap::GetDrives ( )
pure virtual

Gets a list of the root directories on this system.

Returns
The list of the drives.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetExecutablePath()

virtual eC_String CGUIFileSysWrap::GetExecutablePath ( )
pure virtual

Returns the absolute path to the current executable

Returns
executable path

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetFileBaseName()

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

Parameters
rkFileNameThe full file name to be examined.
Returns
The file's base name without path and extension (extension begins after the filename's last dot)
Remarks
This method only performs string operations. It does not check for existence of paths or files.

◆ GetFileDateTime()

virtual time_t CGUIFileSysWrap::GetFileDateTime ( const eC_String &  kPath) const
virtual

Get the last time of modification of the file

Parameters
kPathFull filename (including path) of the file which is getting the last modification
Returns
time and date of the last modification

Reimplemented in CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetFileName()

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

Parameters
rkFileNameThe full file name to be examined.
Returns
The file name without the path.
Remarks
This method only performs string operations. It does not check for existence of paths or files.

◆ GetFileSize()

virtual long CGUIFileSysWrap::GetFileSize ( const eC_String &  kPath) const
virtual

Get the size of the file

Parameters
kPathFull filename (including path) of the file which is getting the size
Returns
size of the file

Reimplemented in CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetFileSuffix()

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

Parameters
rkFileNameThe full file name to be examined.
Returns
The extension without path and file name.
Remarks
This method only performs string operations. It does not check for existence of paths or files.

◆ GetHomePath()

virtual eC_String CGUIFileSysWrap::GetHomePath ( ) const
pure virtual

Get the current user's home path.

Returns
User's home path.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetInstance()

static CGUIFileSysWrap & CGUIFileSysWrap::GetInstance ( )
static

return instance

Returns
instance

◆ GetPath()

eC_String CGUIFileSysWrap::GetPath ( const eC_String &  rkFileName) const

Extracts the path from a file name that includes a path.

Parameters
rkFileNameThe full file name to be examined.
Returns
The path without the file name.
Remarks
This method only performs string operations. It does not check for existence of paths or files.

◆ GetPOSIXDirSeparator()

const eC_String & CGUIFileSysWrap::GetPOSIXDirSeparator ( ) const
inline

Returns the *NIX directory separator.

Returns
An eC_String containing a slash.

◆ GetRootPath()

virtual const eC_String & CGUIFileSysWrap::GetRootPath ( ) const
pure virtual

Gets the absolute path for the root directory.

Returns
The absolute path for the root directory.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ GetWinDirSeparator()

const eC_String & CGUIFileSysWrap::GetWinDirSeparator ( ) const
inline

Returns the windows directory separator.

Returns
An eC_String containing a backslash.

◆ IsDrive()

virtual eC_Bool CGUIFileSysWrap::IsDrive ( const eC_String &  kDirStr) const
pure virtual

Check whether the given directory string represents a drive or not.

Parameters
kDirStrThe directory string to be checked.
Returns
True if the directory name represents a drive; otherwise False.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ IsStrAbsolute()

virtual eC_Bool CGUIFileSysWrap::IsStrAbsolute ( const eC_String &  kStr) const
pure virtual

Help function to check whether the given path string is an absolute path or not.

Parameters
kStrThe given path.
Returns
True, if it is an absolute path; False otherwise.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ MakeAbsolutePath()

eC_Bool CGUIFileSysWrap::MakeAbsolutePath ( const eC_String &  kRelPath,
eC_String &  kAbsPath 
) const

Converts a relative path to an absolute path using the current directory.

Parameters
kRelPathrelative path
kAbsPathabsolute path as return value
Returns
true, if successful, false otherwise

◆ MakeDirectoryPath()

virtual eC_String CGUIFileSysWrap::MakeDirectoryPath ( const eC_String &  kPath) const
virtual

Adds a dir separator at the end of the given path, if there isn't already one.

Parameters
kPathPath to adjust.
Returns
The resulting string

◆ MakeNormalizedPlatformPath()

virtual eC_Bool CGUIFileSysWrap::MakeNormalizedPlatformPath ( const eC_String &  kOrgPath,
eC_String &  kResultPath 
) const
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:\").

Parameters
kOrgPathThe original path to be adjusted.
kResultPathThe resulting path.
Returns
True if successful, False otherwise.

◆ MakePlatformPath()

virtual eC_String CGUIFileSysWrap::MakePlatformPath ( const eC_String &  kOrgPath) const
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:\").

Parameters
kOrgPathThe original path to be adjusted.
Returns
The resulting platform-conforming path.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ OpenPlatformFile()

virtual eC_File * CGUIFileSysWrap::OpenPlatformFile ( const eC_String &  kPath,
eC_Flag  uiMode = eC_File::FS_WRITEACCESS|eC_File::FS_READACCESS 
) const
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.

Parameters
kPathFull filename (including path) of the file which shall be opened
uiModeRequested access mode (see eC_File for details)
Returns
Pointer to newly allocated and opened file. Note that it is in the caller's responsibility to close and free this file! You should check the returned file for errors using eC_File's interfaces.

Reimplemented in CGUIFileSysWrapWin.

◆ RemoveFile()

virtual eC_Bool CGUIFileSysWrap::RemoveFile ( const eC_String &  kPath) const
pure virtual

Removes the file specified with the given absolute path name

Parameters
kPathName of the file to be deleted
Returns
True if successful; otherwise False.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

◆ SeparateString()

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.

Parameters
kOrgStrThe original string that needs to be analyzed.
kLeftStrThe left part of the result string.
kRightStrThe right part of the result string.
kSeparatorThe separator character stored as a string.
bFromLeftIndicate whether the first appearance of the separator is searched from left or right (beginning or end) of kOrgStr.

◆ SetCurrentPath()

virtual eC_Bool CGUIFileSysWrap::SetCurrentPath ( const eC_String &  kPath)
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.

Parameters
kPathThe path to set
Returns
True if the directory was successfully changed; otherwise False.

Implemented in CGUIFileSysWrapDummy, CGUIFileSysWrapPOSIX, and CGUIFileSysWrapWin.

Member Data Documentation

◆ m_kCurrentPath

eC_String CGUIFileSysWrap::m_kCurrentPath
protected

The current application path.

◆ m_kDrivesList

CGUIDirInfo::DirInfoPtrList_t CGUIFileSysWrap::m_kDrivesList
protected

The list of drives in the system. It is initialized every time the user calls GetDrives.


The documentation for this class was generated from the following file: