zeus::TDirectory Class Reference

#include <Directory.h>

Inheritance diagram for zeus::TDirectory:

zeus::TZObject zeus::IZUnknown

List of all members.

Public Types

enum  EFolderType {
  etCommonAdminTools, etCommonAltStartup, etCommonApplicationData, etCommonDesktop,
  etCommonDocuments, etCommonFavorits, etCommonPrograms, etCommonStartMenu,
  etCommonStartup, etCommonTemplates, etControls, etCookies,
  etDesktop, etDrives, etFonts, etHistory,
  etInternet, etInternetCache, etLibraries, etLocalApplicationData,
  etMyMusic, etMyPictures, etNetHood, etNetwork,
  etPrinters, etPrintHood, etProfile, etProgramFiles,
  etProgramFilesCommon, etRecent, etSendTo, etSystem,
  etTrashBin, etUserAdminTools, etUserAltStartup, etUserApplicationData,
  etUserDesktop, etUserDocuments, etUserFavorits, etUserHome,
  etUserPrograms, etUserStartmenu, etUserStartup, etUserTemplates,
  etMedia
}

Public Member Functions

 TDirectory ()
 TDirectory (const TString &strDirName)
 TDirectory (const TDirectoryItem &rItem)
 TDirectory (const TDirectory &rDirectory)
virtual ~TDirectory ()
const TStringgetDirName () const
Retval makeAbsolute (const TString &strBasePath, bool bMustExists)
bool makeDirectory (bool bCreateDeep=false)
bool removeDirectory ()
bool rename (const TString &strNewName)
bool isAbsolute () const
bool exists () const
bool equals (const TDirectory &rDirectory) const
bool equals (const IString &rDirectoryName) const
Retval getDirectoryContent (IList< TDirectoryItem > &rList) const
Retval getDirectoryContent (IList< TDirectoryItem > &rList, const TString &rFilter) const
bool setFilesReadOnly (bool bValue, bool bRecursive)
void simplifyPathName (bool *pbError=NULL)
TDirectoryoperator= (const TDirectory &rDirectory)
bool operator== (const TDirectory &rDirectory) const
bool operator== (const TString &rDirectory) const
bool operator!= (const TDirectory &rDirectory) const
bool operator!= (const TString &rDirectory) const
TString toString () const

Static Public Member Functions

static TDirectory getCurrentDirectory (bool &rError)
static Retval setCurrentDirectory (const IString &strDirectory)
static TDirectory getWorkingDirectory (bool &rError)
static bool setFilesReadOnly (const IString &strDirectory, bool bValue, bool bRecursive)
static Retval setWorkingDirectory (const IString &strDirectory)
static TString simplifyPathName (const IString &rstrPathName, bool *pbError=NULL)
static TDirectory getUserDirectory (bool &rError)
static TDirectory getTempDirectory (bool &rError)
static TDirectory getSystemDirectory (EFolderType eFolder, bool &rError)
static Retval getSystemDirName (EFolderType eFolder, TString &rDirName)


Detailed Description

The directory class implements methods to access the system directory

Member Enumeration Documentation

Enumeration type for folder locations

Enumerator:
etCommonAdminTools  only for windows (CSIDL_COMMON_ADMINTOOLS)
etCommonAltStartup  only for windows (CSIDL_COMMON_ALTSTARTUP)
etCommonApplicationData  linux: [/etc]; windows (CSIDL_COMMON_APPDATA)
etCommonDesktop  only for windows (CSIDL_COMMON_DESKTOPDIRECTORY)
etCommonDocuments  only for windows (CSIDL_COMMON_DOCUMENTS)
etCommonFavorits  only for windows (CSIDL_COMMON_FAVORITES)
etCommonPrograms  linux: [/usr/bin]; windows (CSIDL_COMMON_PROGRAMS)
etCommonStartMenu  only for windows (CSIDL_COMMON_STARTMENU)
etCommonStartup  only for windows (CSIDL_COMMON_STARTUP)
etCommonTemplates  only for windows (CSIDL_COMMON_TEMPLATES)
etControls  only for windows (CSIDL_CONTROLS)
etCookies  only for windows (CSIDL_COOKIES)
etDesktop  only for windows (CSIDL_DESKTOPDIRECTORY)
etDrives  only for windows (CSIDL_DRIVES)
etFonts  only for windows (CSIDL_FONTS)
etHistory  only for windows (CSIDL_HISTORY)
etInternet  only for windows (CSIDL_INTERNET)
etInternetCache  only for windows (CSIDL_INTERNET_CACHE)
etLibraries  linux: [/usr/local/lib]; windows (CSIDL_SYSTEM)
etLocalApplicationData  linux: [/usr/local/etc]; windows (CSIDL_LOCAL_APPDATA); Variable =
etMyMusic  only for windows (CSIDL_MYMUSIC)
etMyPictures  only for windows (CSIDL_MYPICTURES)
etNetHood  only for windows (CSIDL_NETHOOD)
etNetwork  only for windows (CSIDL_NETWORK)
etPrinters  only for windows (CSIDL_PRINTERS)
etPrintHood  only for windows (CSIDL_PRINTHOOD)
etProfile  linux: [/home/USER]; windows (CSIDL_PROFILE)
etProgramFiles  linux: [/usr/local/bin]; windows (CSIDL_PROGRAM_FILES) Variable =
etProgramFilesCommon  linux: [/usr/local/share]; windows (CSIDL_PROGRAM_FILES_COMMON)
etRecent  only for windows (CSIDL_RECENT)
etSendTo  only for windows (CSIDL_SENDTO)
etSystem  linux: [/proc]; windows (CSIDL_WINDOWS)
etTrashBin  linux: [/home/USER/Desktop/trash]; windows (CSIDL_BITBUCKET)
etUserAdminTools  only for windows (CSIDL_ADMINTOOLS)
etUserAltStartup  only for windows (CSIDL_ALTSTARTUP)
etUserApplicationData  linux: [/home/USER]; windows (CSIDL_APPDATA)
etUserDesktop  linux: [/home/USER/Desktop]; windows (CSIDL_DESKTOP)
etUserDocuments  inux: [/home/USER/Documents]; windows (CSIDL_PERSONAL)
etUserFavorits  only for windows (CSIDL_FAVORITES)
etUserHome  linux: [/home/USER]; windows (CSIDL_PROFILE)
etUserPrograms  linux: [/home/USER/bin]; windows (CSIDL_PROGRAMS)
etUserStartmenu  only for windows (CSIDL_STARTMENU)
etUserStartup  only for windows (CSIDL_STARTUP)
etUserTemplates  only for windows (CSIDL_TEMPLATES)
etMedia  only for linux [/media]


Constructor & Destructor Documentation

TDirectory::TDirectory (  ) 

Creates an Directory wrapper object

TDirectory::TDirectory ( const TString strDirName  ) 

Creates an new Directory wrapper object

Parameters:
strDirName : Name of the directory

TDirectory::TDirectory ( const TDirectoryItem rItem  ) 

Creates an new Directory wrapper object out of the directory item

Parameters:
rItem : Item containing the path information

TDirectory::TDirectory ( const TDirectory rDirectory  ) 

Copy constructor

Parameters:
rDirectory : Directory to copy

TDirectory::~TDirectory (  )  [virtual]

Destroys the Directory wrapper object


Member Function Documentation

const TString & zeus::TDirectory::getDirName (  )  const [inline]

Returns the absolute name of the directory

Retval TDirectory::makeAbsolute ( const TString strBasePath,
bool  bMustExists 
)

This builds an abolute path if a path is not absolute yet. The base path will be assembled with this path.

Parameters:
strBasePath : base path (must be absolute)
bMustExists : if the assembled path does not exists, the method will return an error.

bool TDirectory::makeDirectory ( bool  bCreateDeep = false  ) 

If a directory does not exists this method will create a new directory. If the directory exists it will simply return true.

Parameters:
bCreateDeep : Creates non existing parent directories if flag is set
Return values:
true : Directory created
false : could not create directory
Todo:
This method is not unsicode compatible for Unix systems

bool TDirectory::removeDirectory (  ) 

If a directory exists this method will remove it. If the directory doesnt exists it will simply return true.

Return values:
true : Directory created
false : could not create directory
Todo:
This method is not unicode compatible for Unix systems

bool TDirectory::rename ( const TString strNewName  ) 

This method renames a directory. It will fail if the new directory exists or if the name is already given to this directory or this does not exists.

Return values:
true : Directory renamed
false : could not rename directory
Todo:
This method is not unicode compatible for Unix systems

bool zeus::TDirectory::isAbsolute (  )  const [inline]

Checks if the directory is a absolute or a relative path

Return values:
true,: path is absolute
false,: path is relative

bool TDirectory::exists (  )  const

Checks if the file exists

Return values:
true : File exists
false : File doesnt exist

bool TDirectory::equals ( const TDirectory rDirectory  )  const

This checks if a directory equals an other directory object. Only the names and not the content are compared.

Parameters:
rDirectory : Object to check
Return values:
true : Object is equal
false,: Object is not equal

bool TDirectory::equals ( const IString rDirectoryName  )  const

This checks if a directory equals an other directory object.

See also:
TDirectory::equals

Retval zeus::TDirectory::getDirectoryContent ( IList< TDirectoryItem > &  rList  )  const [inline]

Returns a list of directory items from this directory

Retval TDirectory::getDirectoryContent ( IList< TDirectoryItem > &  rList,
const TString rFilter 
) const

Returns a list of directory items from this directory

Parameters:
rList : List of items to return. Each item of this list must be released by the caller
rFilter : Filter if the searching
Return values:
RET_NOERROR : List returned
RET_REQUEST_FAILED : Could not read this directory
Todo:
This method is not unicode compatible for Unix systems. Also Filter is not supported yet

bool TDirectory::setFilesReadOnly ( bool  bValue,
bool  bRecursive 
)

sets the readonly flag to all files of a given folder.

Parameters:
bValue : readonly flag. True = read only
bRecursive : Flag if all file recursivly (including subfolders) are affected of the change
Return values:
true : flags set
false : invalid folder

void zeus::TDirectory::simplifyPathName ( bool *  pbError = NULL  )  [inline]

simplifies the path name

TDirectory & TDirectory::operator= ( const TDirectory rDirectory  ) 

Copy operator

Parameters:
rDirectory : Directory to copy

bool zeus::TDirectory::operator== ( const TDirectory rDirectory  )  const [inline]

Checks if two directories are equal

bool zeus::TDirectory::operator== ( const TString rDirectory  )  const [inline]

Checks if two directories are equal

bool zeus::TDirectory::operator!= ( const TDirectory rDirectory  )  const [inline]

Checks if two directories are equal

bool zeus::TDirectory::operator!= ( const TString rDirectory  )  const [inline]

Checks if two directories are equal

TString zeus::TDirectory::toString (  )  const [inline]

See also:
TZObject::toString

Reimplemented from zeus::TZObject.

static TDirectory zeus::TDirectory::getCurrentDirectory ( bool &  rError  )  [inline, static]

static Retval zeus::TDirectory::setCurrentDirectory ( const IString strDirectory  )  [inline, static]

TDirectory TDirectory::getWorkingDirectory ( bool &  rError  )  [static]

Static method to receive the current working directory

Todo:
This method is not unicode compatible for Unix systems

bool zeus::TDirectory::setFilesReadOnly ( const IString strDirectory,
bool  bValue,
bool  bRecursive 
) [inline, static]

sets the readonly flag to all files of a given folder.

Parameters:
strDirectory : Name of the folder
bValue : readonly flag. True = read only
bRecursive : Flag if all file recursivly (including subfolders) are affected of the change
Return values:
true : flags set
false : invalid folder

Retval TDirectory::setWorkingDirectory ( const IString strDirectory  )  [static]

Static method to set the current working directory.

Todo:
This method is not implemented for Unix systems

TString TDirectory::simplifyPathName ( const IString rstrPathName,
bool *  pbError = NULL 
) [static]

simplifies the path name. Elements such as .. are removed

TDirectory TDirectory::getUserDirectory ( bool &  rError  )  [static]

This method returns the home directory of a user. For Unix systems it will simply return the '~'. For windows systems the absolute home directory of the current user will be returned

Parameters:
rError : returns true if an error occured
Returns:
user directory

TDirectory TDirectory::getTempDirectory ( bool &  rError  )  [static]

This method returns the temporary file directory of a system

Parameters:
rError : returns true if an error occured
Returns:
temp directory

TDirectory TDirectory::getSystemDirectory ( EFolderType  eFolder,
bool &  rError 
) [static]

This method returns the directory instance of a system directory.

Parameters:
eFolder : Folder type (see enumeration)
rError : returns true if an error occured
Returns:
system directory

Retval TDirectory::getSystemDirName ( EFolderType  eFolder,
TString rDirName 
) [static]

This method returns the name of a system directory.

Parameters:
eFolder : Folder type (see enumeration)
rDirName : Return parameter of the system directory
Return values:
RET_NOERROR : System directory name returned
RET_REQUEST_FAILED : Could not find system directory


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


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Wed Oct 28 21:42:34 2009