ADTF  v2.14.3
cFileSystem Class Reference

File system class. More...

Public Types

enum  { ED_DEFAULT = 0x0, ED_FILES = 0x1, ED_DIRECTORIES = 0x2 }
 
enum  FilePermissionFlag {
  PERM_USR_RD = 0x0400, PERM_USR_WR = 0x0200, PERM_USR_EX = 0x0100, PERM_GRP_RD = 0x0040,
  PERM_GRP_WR = 0x0020, PERM_GRP_EX = 0x0010, PERM_OTH_RD = 0x0004, PERM_OTH_WR = 0x0002,
  PERM_OTH_EX = 0x0001, PERM_SUID = 0x4000, PERM_SGID = 0x2000, PERM_SVTX = 0x1000
}
 File permission flags. More...
 

Static Public Member Functions

static tUInt32 GetFileAttrib (const cFilename &strFilename)
 Get the file attributes of a specified file. More...
 
static tBool ReadTextFile (const cFilename &strFilename, cString &strString, const tUInt32 &ui32OpenMode=cFile::OM_Read|cFile::OM_SequentialAccess)
 This function reads a complete text file into a cString object. More...
 
static tBool WriteTextFile (const cFilename &strFilename, const cString &strString)
 This function creates a text file from an existing cString object. More...
 
static tBool Exists (const cFilename &strFilename)
 This function checks if a file or directory exists. More...
 
static tFileSize GetFileSize (const cFilename &strFilename)
 This function gets the size of a file in bytes. More...
 
static tBool IsFile (const cFilename &strFilename)
 This function checks if the specified filename points to a file. More...
 
static tBool IsDirectory (const cFilename &strFilename)
 This function checks if the specified filename points to a directory. More...
 
static tBool CreatePath (const cFilename &strDirName, tBool bRecursive=false)
 This function creates a directory. More...
 
static tBool IsReadOnly (const cFilename &strFilename)
 This function checks if a file is read-only. More...
 
static tBool SetReadOnly (const cFilename &strFilename, tBool bReadOnly=true)
 This function sets or removes the read-only flag for a file. More...
 
static tResult DelFile (const cFilename &strFilename)
 Deletes a File. More...
 
static tResult DelDirectory (const cFilename &strDirectory)
 Deletes a Directory. More...
 
static cFilename GetCurDirectory ()
 Returns the current working directory. More...
 
static tBool SetCurDirectory (const cFilename &strDirName)
 Changes the current working directory. More...
 
static cFilename GetAppDirectory ()
 Returns the directory where the executable resides. More...
 
static cFilename GetSysDirectory ()
 Returns the system directory (e.g. More...
 
static cFilename GetOwnModuleDirectory ()
 For instance a DLL or shared library file is loaded within another application. More...
 
static cFilename GetUserApplicationDirectory (const cString &strApplication=cString::Empty)
 Returns the application data directory of the current user. More...
 
static cFilename GetTempDirectory ()
 Returns the temp directory. More...
 
static tBool FileCopy (const cString &strFrom, const cString &strTo)
 Copies a file to another location. More...
 
static tBool FolderCopy (const cFilename &strFrom, const cFilename &strTo)
 Copies a folder recursively to another location. More...
 
static tBool Move (const cFilename &strFrom, const cFilename &strTo)
 Moves a folder or file. More...
 
static tUInt32 GetFilePermissions (const cFilename &strFilename)
 Returns the permission set of a file. More...
 
static tBool SetFilePermissions (const cFilename &strFilename, tUInt32 nPermissionMask)
 Sets the permission set of a file. More...
 
static tInt GetDefaultSectorSize ()
 Get the default sector size. More...
 
static tInt GetSectorSize (const cFilename &strFilename)
 Get the sector size of the filesystem that a specified file resides on. More...
 
static tVoidAllocPageAlignedMemory (tInt nSize, tInt nPageSize=0)
 Allocates memory that is page aligned. More...
 
static tVoid FreePageAlignedMemory (tVoid *pMemory)
 Free memory that has been allocated using AllocPageAlignedMemory. More...
 
static tResult EnumDirectory (const cFilename &strDir, cStringList &lstFiles, tUInt32 ui32Flags=0)
 Lists all entries in a directory. More...
 
static tResult GetFreeDiskSpace (const tChar *strFolder, tUInt64 *pui64FreeBytes)
 Returns the free diskspace on the media that the given path resides on. More...
 
static tResult FindFiles (const cString &strPattern, cStringList &lstFiles)
 Search for files matching a specific pattern. More...
 
static tResult FindFolders (const cString &strPattern, cStringList &lstFolders)
 Searches for folders matching a specific pattern. More...
 
static tResult GetTimeAccess (const cFilename filename, adtf_util::cDateTime &dt)
 This function returns the last access time of the file. More...
 
static tResult GetTimeCreation (const cFilename filename, adtf_util::cDateTime &dt)
 This function returns the creation time of the file. More...
 
static tResult GetTimeChange (const cFilename filename, adtf_util::cDateTime &dt)
 This function returns the last change (write) time of the file. More...
 
static tInt GetLastErrorCode ()
 Gets the error code of the last failure. More...
 
static tResult RenameFilename (cFilename oldFileName, cFilename newFileName)
 The rename function shall change the name of a file. More...
 

Static Protected Attributes

static cFilename m_strLastBrowseDir
 currently not in use More...
 
static tUInt32 m_ui32DefaultSectorSize
 the default sector size of the system / drive / device
 

Detailed Description

File system class.

Definition at line 201 of file filesystem.h.

Member Enumeration Documentation

File permission flags.

See also
cFileSystem::SetFilePermissions, cFileSystem::GetFilePermissions.

Definition at line 215 of file filesystem.h.

Member Function Documentation

static tVoid* AllocPageAlignedMemory ( tInt  nSize,
tInt  nPageSize = 0 
)
static

Allocates memory that is page aligned.

Parameters
nSize[in] How much memory should be allocated (Bytes).
nPageSize[in] The size of a page, autodetected if = 0.
Returns
A pointer the the allocated memory.
static tBool CreatePath ( const cFilename strDirName,
tBool  bRecursive = false 
)
static

This function creates a directory.

If the parent directory structure doesn't exist, the bRecursive option causes this to be created as well.

Note
This function will always return tTrue if strDirName is empty because it considers this to be the current path which exists per definition. However, this is not checked.
Parameters
strDirName[in] Path or name of directory to be created. If empty, function returns tTrue.
bRecursive[in] Flag for creating the whole parent directory structure.
Returns
Returns true if the directory was created (or already exists), otherwise false.
Remarks
It returns false, if a file with the same name already exists. It returns true, if a directory with the same name already exists (it doesn't matter if the existing directory is empty or not).
static tResult DelDirectory ( const cFilename strDirectory)
static

Deletes a Directory.

Parameters
strDirectory[in] name of the directory to be deleted
Return values
ERR_ACCESS_DENIEDif failed.
ERR_NOERRORif succeeded.
Remarks
Replaces: RemoveDirectory.
static tResult DelFile ( const cFilename strFilename)
static

Deletes a File.

Parameters
strFilename[in] name of the file to be deleted
Return values
StandardError Code.
ERR_ACCESS_DENIEDif failed.
ERR_NOERRORif succeeded.
Remarks
Replaces: RemoveFile.
static tResult EnumDirectory ( const cFilename strDir,
cStringList lstFiles,
tUInt32  ui32Flags = 0 
)
static

Lists all entries in a directory.

Parameters
strDir[in] The directory.
lstFiles[out] The list of entries.
ui32Flags[in] Whether to list files (ED_FILES) or directories (ED_DIRECTORIES). Default is files only.
Returns
Standard Result Code.
static tBool Exists ( const cFilename strFilename)
static

This function checks if a file or directory exists.

Parameters
strFilename[in] Path of file or directory to be checked for.
Returns
Returns true, if the file or directory exists, otherwise false.
static tBool FileCopy ( const cString strFrom,
const cString strTo 
)
static

Copies a file to another location.

Parameters
strFrom[in] The source filename.
strTo[in] The destination filename.
Returns
tTrue if successfull, otherwise tFalse.
static tResult FindFiles ( const cString strPattern,
cStringList lstFiles 
)
static

Search for files matching a specific pattern.

The pattern strPattern can be a relative or absolute filepath. The pattern has to be of one of the following forms:

  • root/a.file : returns a.file, if exists
  • root/*.file : match all files with ending .file in the root folder
  • root/* : returns all files in root folder (no recursion!)
  • root/*.* : same as root/*
  • root/*/a.file : search for a.file in every subfolder of root (no recursion!)
  • root/**/*.* : returns all files in root and every subfolder recursively!
  • root/**/* : same as root/**/*.*
  • root/**/sub/a.file : search for sub/a.file in every subfolder of root recursively
  • root/a*cc.file : use * as a wildcard within filenames.
Parameters
strPattern[in] The pattern to match.
lstFiles[out] The list of found files.
Return values
ERR_NOERRORif files are found,
ERR_NOT_FOUNDotherwise.
static tResult FindFolders ( const cString strPattern,
cStringList lstFolders 
)
static

Searches for folders matching a specific pattern.

Wildcard * is the only one allowed.

Parameters
strPattern[in] The pattern to match.
lstFolders[out] The list of found folders.
Return values
ERR_NOERRORif folders are found,
ERR_NOT_FOUNDotherwise.
static tBool FolderCopy ( const cFilename strFrom,
const cFilename strTo 
)
static

Copies a folder recursively to another location.

Parameters
strFrom[in] The source folder.
strTo[in] The destination filename.
Returns
tTrue if successfull, otherwise tFalse.
static tVoid FreePageAlignedMemory ( tVoid pMemory)
static

Free memory that has been allocated using AllocPageAlignedMemory.

Parameters
pMemory[in] Pointer the the allocated memory.
Returns
void
static cFilename GetAppDirectory ( )
static

Returns the directory where the executable resides.

Returns
The directory where the executable resides without a trailing slash.
static cFilename GetCurDirectory ( )
static

Returns the current working directory.

Note
the trailing slash is here to remain compatible with older releases.
Returns
The current working directory WITH a trailing slash.
static tInt GetDefaultSectorSize ( )
static

Get the default sector size.

Returns
The default sector size.
static tUInt32 GetFileAttrib ( const cFilename strFilename)
static

Get the file attributes of a specified file.

Parameters
strFilename[in] The filename.
Returns
The bit mask of the attributes.
See also
cFileAttributes
static tUInt32 GetFilePermissions ( const cFilename strFilename)
static

Returns the permission set of a file.

Currently only implemented for Linux.

Parameters
strFilename[in] The filename.
See also
FilePermissionFlag
SetFilePermissions
SetReadOnly
Returns
The permission set of a file. If executed under windows, this returns 0x0777 which translate into all rights if the specified file exists. If the specified file does not exist or an error occured, 0xFFFFFFFF is returned
static tFileSize GetFileSize ( const cFilename strFilename)
static

This function gets the size of a file in bytes.

Note
On Windows, this function only works if the requested file is not already opened by cFile::Open().
Parameters
strFilename[in] name of the file
Returns
Returns the size of the file in bytes.
static tResult GetFreeDiskSpace ( const tChar strFolder,
tUInt64 pui64FreeBytes 
)
static

Returns the free diskspace on the media that the given path resides on.

Parameters
strFolder[in] The pathname. Must be absolute!
pui64FreeBytes[out] The free space in bytes, or 0 in case of failure or if strFolder was NULL
Returns
Standard Result Code
static tInt GetLastErrorCode ( )
static

Gets the error code of the last failure.

Returns
The error code of the last failure.
static cFilename GetOwnModuleDirectory ( )
static

For instance a DLL or shared library file is loaded within another application.

This function - called within the DLL or shared library file - returns the directory where the file resides in the file system. In other words: if called within a DLL or shared library file, it returns the own file system path of the file itself.

Returns
The directory of a loaded DLL or shared library file without a trailing slash.
static tInt GetSectorSize ( const cFilename strFilename)
static

Get the sector size of the filesystem that a specified file resides on.

Parameters
strFilename[in] The filename.
Returns
The sector size.
static cFilename GetSysDirectory ( )
static

Returns the system directory (e.g.

system32 or /etc on unix).

Returns
The system directory without a trailing slash.
static cFilename GetTempDirectory ( )
static

Returns the temp directory.

Returns
The temp directory without a trailing slash.
static tResult GetTimeAccess ( const cFilename  filename,
adtf_util::cDateTime dt 
)
static

This function returns the last access time of the file.

Parameters
dtA_UTILS_NS::cDateTime of the last access
filenamecFilename of the file to be checked
Return values
OKif the time has been retrieved
ERR_INVALID_ARGif filename is empty
ERR_UNKNOWNif time cannot be read
static tResult GetTimeChange ( const cFilename  filename,
adtf_util::cDateTime dt 
)
static

This function returns the last change (write) time of the file.

Parameters
dtA_UTILS_NS::cDateTime of the last access
filenamecFilename of the file to be checked
Return values
OKif the time has been retrieved
ERR_INVALID_ARGif filename is empty
ERR_UNKNOWNif time cannot be read;
static tResult GetTimeCreation ( const cFilename  filename,
adtf_util::cDateTime dt 
)
static

This function returns the creation time of the file.

Parameters
dtA_UTILS_NS::cDateTime of the last access
filenamecFilename of the file to be checked
Return values
OKif the time has been retrieved
ERR_INVALID_ARGif filename is empty
ERR_UNKNOWNif time cannot be read;
static cFilename GetUserApplicationDirectory ( const cString strApplication = cString::Empty)
static

Returns the application data directory of the current user.

Parameters
[in]strApplicationadditional path to be added to the user directory
Returns
The application data directory without a trailing slash.
static tBool IsDirectory ( const cFilename strFilename)
static

This function checks if the specified filename points to a directory.

Parameters
strFilename[in] Path of directory to be checked for.
Returns
Returns true, if the specified object is a directory, otherwise false.
static tBool IsFile ( const cFilename strFilename)
static

This function checks if the specified filename points to a file.

Parameters
strFilename[in] Path of file to be checked for.
Returns
Returns true, if the specified object is a file, otherwise false.
static tBool IsReadOnly ( const cFilename strFilename)
static

This function checks if a file is read-only.

Parameters
strFilename[in] Path of file to be checked.
Returns
Returns true, if the file is read-only, otherwise false.
static tBool Move ( const cFilename strFrom,
const cFilename strTo 
)
static

Moves a folder or file.

Parameters
strFrom[in] The source filename.
strTo[in] The destination filename.
Returns
tTrue if successfull, otherwise tFalse.
static tBool ReadTextFile ( const cFilename strFilename,
cString strString,
const tUInt32 ui32OpenMode = cFile::OM_Read|cFile::OM_SequentialAccess 
)
static

This function reads a complete text file into a cString object.

Parameters
strFilename[in] Path of file to be read.
strString[in] cString object to be filled.
ui32OpenMode[in] Open Mode of the File see cFile::tOpenMode (should be at least cFile::OM_Read)
Returns
Returns true, if the file was read successfully, otherwise false.
static tResult RenameFilename ( cFilename  oldFileName,
cFilename  newFileName 
)
static

The rename function shall change the name of a file.

Parameters
oldFileNameThe old argument points to the pathname of the file to be renamed
newFileNameThe new argument points to the new pathname of the file
Return values
OKif the time has been retrieved
ERR_UNKNOWNif time cannot be read;
static tBool SetCurDirectory ( const cFilename strDirName)
static

Changes the current working directory.

Parameters
strDirName[in] The path to the new working directory.
Returns
tTrue if successful, otherwise tFalse.
static tBool SetFilePermissions ( const cFilename strFilename,
tUInt32  nPermissionMask 
)
static

Sets the permission set of a file.

Currently only implemented for Linux.

Parameters
strFilename[in] The filename.
nPermissionMask[in] The new permission set.
See also
FilePermissionFlag
GetFilePermissions
Returns
tTrue if successfull, otherwise tFalse. Windows: Always returns tFalse.
static tBool SetReadOnly ( const cFilename strFilename,
tBool  bReadOnly = true 
)
static

This function sets or removes the read-only flag for a file.

Parameters
strFilename[in] Path of file to be modified.
bReadOnly[in] Set or remove the read only flag.
Returns
Returns true, if the file was modified, otherwise false.
static tBool WriteTextFile ( const cFilename strFilename,
const cString strString 
)
static

This function creates a text file from an existing cString object.

Parameters
strFilename[in] Path of file to be written.
strString[in] cString object as data source.
Returns
Returns true, if the file was written successfully, otherwise false.

Member Data Documentation

cFilename m_strLastBrowseDir
staticprotected

currently not in use

Definition at line 236 of file filesystem.h.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)