System file and directory services class. More...
#include <mi32/filepath.h>
System file and directory services class.
| enum FILEPATH::CHILDTYPE |
File system types as can be determined.
| enum FILEPATH::PATHTYPE |
Common file path types.
| enum FILEPATH::PERMISSION |
| FILEPATH::FILEPATH | ( | ) | [inline] |
Default constructor, empty path.
| FILEPATH::FILEPATH | ( | const FILEPATH & | rhs | ) | [inline] |
Copy constructor.
Concatenation constructor, 'dir' must be a directory.
Concatenation constructor, 'dir' must be a directory.
| FILEPATH::FILEPATH | ( | const FILEPATH & | dir, | |
| const char * | name, | |||
| CHAR_ENCODING | encoding = CHAR_ENCODING_ASCII | |||
| ) |
Concatenation constructor, 'dir' must be a directory.
| FILEPATH::FILEPATH | ( | PATHTYPE | type | ) | [explicit] |
Constructor, inialize with a system path.
| FILEPATH::FILEPATH | ( | const MIUNICODE * | rhs | ) |
Constructor, initialize with MIUNICODE*, for compatibility.
| FILEPATH::FILEPATH | ( | const char * | rhs, | |
| CHAR_ENCODING | encoding = CHAR_ENCODING_ASCII | |||
| ) | [explicit] |
Constructor, initialize with C string, for efficiency.
| FILEPATH::FILEPATH | ( | void * | IniHandle, | |
| const char * | group, | |||
| const char * | field | |||
| ) |
Initialize a FILEPATH with an entry from an INI file.
| IniHandle | Handle to INI file to read from, 0 for default file "tntproc.ini" | |
| group | INI group to read path from | |
| field | INI field to read path from |
| FILEPATH::~FILEPATH | ( | ) | [inline] |
Destructor.
| FILEPATH& FILEPATH::Append | ( | const char * | q, | |
| CHAR_ENCODING | encoding | |||
| ) |
Append a string to FILEPATH, adding separator.
| q | String to append with | |
| encoding | Encoding of the string |
| FILEPATH& FILEPATH::Assign | ( | const char * | p, | |
| CHAR_ENCODING | encoding = CHAR_ENCODING_ASCII | |||
| ) |
Assign a character string representation of a path to FILEPATH using the character encoding.
| ERRVALUE FILEPATH::CheckAccess | ( | const PERMISSION | perm = PERMISSION_Read |
) | const |
Check access permissions on the file / directory.
| perm | Access permission to check for |
| void FILEPATH::Clear | ( | ) |
Clear the path representation.
| bool FILEPATH::Contains | ( | const FILEPATH & | SubPath | ) | const |
Check if path contains "subpath" given.
| SubPath | Subpath to check against |
Convert user displayable into a component OS filename Only has an effect on MAC_OSX where the slash '/' is transposed to a colon ':' from displaying.
Convert component OS filename passed in to a displayable filename.
Only has an effect on MAC_OSX where the colon ':' is transposed to a slash '/' when displaying
Copy contents from SourcePath.
Uses MISTATUSCONTEXT to report file copying progress
| SourcePath | Source file to copy from |
| void FILEPATH::CopyFileFromDetached | ( | const FILEPATH & | SourcePath, | |
| MISTATUSMANAGER * | DftManager = 0 | |||
| ) | const |
Copy contents from SourcePath.
This method creates a MITHREAD::WORKER_DETACHED derived class to copy the file, therefore this method is asynchronous and will return immediately.
| SourcePath | Source file to copy from | |
| DftManager | Default status manager to assign any job, unless job overrides it |
| bool FILEPATH::Exists | ( | ) | const |
Check if path exists.
| char* FILEPATH::GenerateEncodedOSPath | ( | ) | const |
Generate Operating system specific path with the proper encoding for character based IO calls.
In some cases this will fail if the path does not exist. Use this method to call functions that take a path ONLY if nothing else can be done and it is a third party library. It is not known if the third party library can handle the multiple encodings if they manipulate the path.
| ERRVALUE FILEPATH::GenerateTempFile | ( | const FILEPATH & | BasePath, | |
| const MISTRING & | Basename, | |||
| const char * | extn = "tmp" | |||
| ) |
Generate a temp file given a basepath and a basename for the temp file Called by FILEFIND::MakeTempFile().
| INT64 FILEPATH::GetAvailableSpace | ( | ) | const |
Returns the amount of free space on the volume that the path represents.
| int FILEPATH::GetChildren | ( | MISTRINGLIST & | ChildList, | |
| const MISTRING & | pattern, | |||
| CHILDTYPE | ChildType | |||
| ) | const |
Obtain a list of child directories or files that exist under this path using a pattern to select which children to find.
| ChildList | List of child names found after search | |
| pattern | Pattern to match | |
| ChildType | Type of children to search for CHILDTYPE_Directory or CHILDTYPE_File. |
| int FILEPATH::GetChildren | ( | MISTRINGLIST & | ChildList, | |
| CHILDTYPE | ChildType | |||
| ) | const |
Obtain a list of child directories or files that exist under this path.
| ChildList | List of child names found after search | |
| ChildType | Type of children to search for CHILDTYPE_Directory or CHILDTYPE_File. |
| int FILEPATH::GetComponents | ( | MISTRINGLIST & | CompList | ) | const |
Separate path into individual components, returns number of components.
| CompList | List of components RETURNED |
| MISTRING FILEPATH::GetDisplay | ( | ) | const |
Get the display string representation for the path.
Used to get a string that is to be displayed to the end user.
| static int FILEPATH::GetDriveList | ( | MISTRINGLIST & | DriveList | ) | [static] |
Determine list of drives / volumes for this OS.
| MISTRING FILEPATH::GetEncoded | ( | ) | const |
Get OS-independent string representation for the path.
Used to get a string that is to be saved to a permanent database / file for later retrieval. The encoding is used in the case of file transfer to different system types, Eg UNIX -> WIN32 or MAC -> WIN32 or any other combination.
| static bool FILEPATH::GetEnvPath | ( | const char * | name, | |
| MISTRING & | EnvPathStr | |||
| ) | [static] |
Get an environment variable as a path (or paths) and convert using the correct OS encoding.
| MISTRING FILEPATH::GetExtension | ( | ) | const |
Get the file name extension, without the extension marker.
The extension is considered to be the string after the last extension marker. Eg. in "test.rvc.txt", 'txt' would be the extension returned.
| FILESYSTYPE FILEPATH::GetFileSysType | ( | ) | const |
Get type of system drive the path represents.
| UINT32 FILEPATH::GetFullPathSizeLimit | ( | ) | const |
Get maximum amount of characters allowed for an operating system's full path.
| MISTRING FILEPATH::GetName | ( | ) | const |
Get the last component name (file or folder) with extension (if exists).
| MISTRING FILEPATH::GetNameOnly | ( | ) | const |
Get the file name only, no extension, unless directory.
A directory is not considered to have an extension, therefore if this path represents a directory, the name with extension is returned.
| UINT32 FILEPATH::GetNameSizeLimit | ( | ) | const |
Get maximum amount of characters allowed for an operating system's path segment.
| static const MISTRING& FILEPATH::GetNonValidComponentChars | ( | ) | [static] |
Get set of characters which are not valid for a path component.
This will include separators and filesystem specifiers.
| INT32 FILEPATH::GetOptimalTransferSize | ( | ) | const |
Get the optimal transfer size for the volume/drive specified.
| MISTRING FILEPATH::GetOSPath | ( | ) | const |
Get the OS-dependent Unicode string representation for the path.
Used to generate valid path string for use in OS-specific file I/O functions where Unicode versions are available. Does not insert quotes around components containing spaces.
| FILEPATH FILEPATH::GetPathOnly | ( | ) | const |
Get the path representation only.
| PERMISSION FILEPATH::GetPermission | ( | ) | const |
Get access permissions on the file / directory.
| MISTRING FILEPATH::GetQuotedPath | ( | ) | const |
Get path with quotes inserted around components containing spaces.
Used to generate a valid string to use command on lines.
| MISTRING FILEPATH::GetRelativePath | ( | const FILEPATH & | BasePath, | |
| RELATIVEPATH | flags, | |||
| int | maxoutlevels = -1, |
|||
| char | separator = 0 | |||
| ) | const |
Generate relative path from specified base with options.
| BasePath | Base path, which returned string is relative to. | |
| flags | Flags | |
| maxoutlevels | Maximum number of outward (../) folder levels, -1 if no limit | |
| separator | Component separator, 0 to use from platform |
Generate an encoded relative path from a source path.
The string returned will be one of three types: 1. A string == ".", the current path and the source path are equal 2. An encoded string from GetEncoded() method, the two paths are completely unrelated 3. An encoded string with the relative path.
See also IsRelativePath().
| BasePath | Base path which the instance is compared to and the relative path is generated against |
| INT64 FILEPATH::GetSize | ( | ) | const |
Return size of the file.
| INT64 FILEPATH::GetSystemMaxSize | ( | ) | const |
Return maximum size of a file on the drive represented.
| ERRVALUE FILEPATH::GetTimeAccessed | ( | time_t * | rettime | ) | const |
Get the access time for the file.
| rettime | UTC time |
| ERRVALUE FILEPATH::GetTimeCreated | ( | time_t * | rettime | ) | const |
Get the creation time for the file.
| rettime | UTC time |
| ERRVALUE FILEPATH::GetTimeModified | ( | time_t * | rettime | ) | const |
Get the modification time for the file.
| rettime | UTC time |
| void FILEPATH::GetVolumeName | ( | MISTRING & | VolumeName | ) | const |
Get root volume name.
| VolumeName | Volume name returned, will be blank if cannot determine |
| bool FILEPATH::HasChildren | ( | CHILDTYPE | ChildType | ) | const |
Does the path have children of a specific type?
| ChildType | Type of children to search for CHILDTYPE_Directory or CHILDTYPE_File. |
| bool FILEPATH::HasExtension | ( | ) | const |
Does the Name part of the path have an extension?
| bool FILEPATH::IniRead | ( | void * | IniHandle, | |
| const char * | group, | |||
| const char * | field | |||
| ) |
Initialize a FILEPATH with an entry from an INI file.
| IniHandle | Handle to INI file to read from, 0 for default file "tntproc.ini" | |
| group | INI group to read path from | |
| field | INI field to read path from |
| void FILEPATH::IniWrite | ( | void * | IniHandle, | |
| const char * | group, | |||
| const char * | field | |||
| ) | const |
Write encoded filepath to .ini file.
| IniHandle | Handle to INI file to write to, 0 for default file "tntproc.ini" | |
| group | INI group to write encoded path to | |
| field | INI field to write encoded path to |
| bool FILEPATH::IsChildPath | ( | const FILEPATH & | BasePath | ) | const |
Is the path a child path of 'BasePath'.
| bool FILEPATH::IsEmpty | ( | ) | const |
Is FILEPATH empty?
| bool FILEPATH::IsEqual | ( | const FILEPATH & | TestPath | ) | const |
Are the paths equal?
Case insensitive check for WIN32, MAC.
| bool FILEPATH::IsFile | ( | ) | const |
Is FILEPATH an existing file?
| bool FILEPATH::IsFolder | ( | ) | const |
Is FILEPATH an existing folder (directory)?
| bool FILEPATH::IsLessThan | ( | const FILEPATH & | TestPath | ) | const |
Is "this" less than testpath?
Case insensitive check for WIN32, MAC.
| bool FILEPATH::IsPathOnly | ( | ) | const |
Is the file referenced a directory?
A non-existant path is a directory.
| bool FILEPATH::IsReadable | ( | ) | const |
Is the path / file readable?
| static bool FILEPATH::IsRelativePath | ( | const MIUNICODE * | path | ) | [static] |
Determine if relative path using MIUNICODE* string.
| path | String to determine if a relative path |
| static bool FILEPATH::IsRelativePath | ( | const MISTRING & | path | ) | [static] |
Is the string given specify a relative path.
A string is considered a relative path if: 1. The string is empty or the string == "." 2. The string starts with a relative path indicator specific for the platform On all but the MAC, the string can start with either the same directory relative path or the parent directory relative path. The MAC does not have a current directory relative path.
Example: if (FILEPATH::IsRelativePath(RelStr)) { FilePath = BasePath; // Assign base path to dest FilePath += RelStr; // Concatinate relative path onto dest } else { FilePath = RelStr; // Full path, assign to dest }
| path | String to determine if a relative path |
| bool FILEPATH::IsRootOnly | ( | ) | const |
Is the path a root path?
| bool FILEPATH::IsSameExtn | ( | const MISTRING & | extn | ) | const |
Does the filepath have the same extension as that passed in This method is used to speed up extension checking without creating one or two MISTRINGs This method uses no-case comparisons.
| extn | Do not prepend extension marker '.' |
| bool FILEPATH::IsSameExtn | ( | const char * | extn | ) | const |
Does the filepath have the same extension as that passed in This method is used to speed up extension checking without creating one or two MISTRINGs This method uses no-case comparisons.
| extn | Do not prepend extension marker '.' |
| bool FILEPATH::IsUNCHostOnly | ( | ) | const |
Is the path a UNC host path only? (\\Machine).
| bool FILEPATH::IsUNCRoot | ( | ) | const |
Is the path a UNC root path? (\\Machine\share).
| static bool FILEPATH::IsValidName | ( | const MISTRING & | name | ) | [static] |
Determine if the path component is valid for the current OS.
| bool FILEPATH::IsWritable | ( | ) | const |
Is the path / file writable?
(Writable is correct spelling).
| ERRVALUE FILEPATH::Make | ( | bool | MakeTree = false |
) | const |
Creates a path.
If 'MakeTree' true, will create all non-existant directories listed in its path.
Creates a hard link to the file 'SrcFile', given the new filename 'this'.
| static bool FILEPATH::MakeValidChars | ( | MISTRING & | name | ) | [static] |
Validate characters in path component for the current OS.
Does not check for reserved names.
| static bool FILEPATH::MakeValidName | ( | MISTRING & | name | ) | [static] |
Validate the path component for the current OS.
| FILEPATH& FILEPATH::operator+= | ( | const char * | rhs | ) |
Concatenate from C string, for efficiency.
| rhs | ASCII encoded string |
Concatenate from MIUNICODE*, adding separator.
Concatenate from MISTRING, adding separator.
| ERRVALUE FILEPATH::Remove | ( | ) | const |
Remove a file from the system, does not remove directories.
| ERRVALUE FILEPATH::RemoveFiles | ( | bool | RemoveReadOnlyFiles = false |
) | const |
Remove files and sub-folders from the system.
This method will not remove 'root' folders or system folders. Even so, use this with caution.
| ERRVALUE FILEPATH::RemoveFolder | ( | ) | const |
Remove a folder from the system, does not remove files.
Move existing file to newpath.
| newname | Path to change to |
Rename an existing file with a new name, FILEPATH changed after sucessful operation.
| newname | Name to change to |
Replace root of the path with a new root.
| SourcePath | Path that contains new root path |
| bool FILEPATH::SearchCase | ( | ) |
Search for file by changing path case incrementally.
| FILEPATH& FILEPATH::SetExtension | ( | const char * | extn, | |
| CHAR_ENCODING | encoding = CHAR_ENCODING_ASCII | |||
| ) |
Set extension of the path.
| static void FILEPATH::SetModuleFileName | ( | const char * | name, | |
| CHAR_ENCODING | encoding | |||
| ) | [static] |
Set application executable name so that PATHTYPE_Executable for SetSystemPath() can work.
Only necessary on Unix and in rare cases on Windows
| name | Name of executable (argv[0] for most systems) | |
| encoding | String encoding (CHAR_ENCODING_ASCII for most systems) |
| FILEPATH& FILEPATH::SetName | ( | const char * | name, | |
| CHAR_ENCODING | encoding = CHAR_ENCODING_ASCII | |||
| ) |
Replace FILEPATH name, overloaded for efficiency.
| ERRVALUE FILEPATH::SetPermission | ( | PERMISSION | perm | ) | const |
Set access permissions on the file / directory.
| perm | Permission to set file / directory to |
| void FILEPATH::SetSystemPath | ( | PATHTYPE | pt | ) |
| ERRVALUE FILEPATH::SetTimeCreated | ( | time_t | value | ) | const |
Change creation time for a file, if possible.
| value | UTC based time value |
| ERRVALUE FILEPATH::SetTimeCreated | ( | const tm *const | timeval | ) | const |
Change creation time for a file, if possible.
| timeval | UTC based time value |
| ERRVALUE FILEPATH::SetTimeModified | ( | time_t | value | ) | const |
Change modification time for a file, if possible.
| value | UTC based time value |
| ERRVALUE FILEPATH::SetTimeModified | ( | const tm *const | timeval | ) | const |
Change modification time for a file, if possible.
| timeval | UTC based time value |
| FILEPATH& FILEPATH::StripExtension | ( | ) |
Strips the extension, if it exists, off of Name.
| FILEPATH& FILEPATH::StripLastComponent | ( | ) |
Strips the last component off of the path.
| bool FILEPATH::StripToCommon | ( | const FILEPATH & | testpath | ) |
Strip to portion in common with specified path.
| FILEPATH& FILEPATH::StripToExisting | ( | ) |
Strips off components until the remaining path exists.
| FILEPATH& FILEPATH::StripToFolder | ( | ) |
Strips off components until the remaining folder path exists.
| FILEPATH& FILEPATH::StripToRoot | ( | ) |
Strips everything off except the root path.
| ERRVALUE FILEPATH::UpdateFilesFrom | ( | const FILEPATH & | SourcePath, | |
| const MISTRING & | pattern, | |||
| bool | RecurseSubDirectories = true | |||
| ) | const |
Update files from the source path to 'this' if the source file is of a later date.
If the directory referenced by 'this' does not exist, it will be created.
| SourcePath | Source directory to update files from | |
| pattern | Pattern to match | |
| RecurseSubDirectories | Update files from subdirectories also |
| ERRVALUE FILEPATH::UpdateFilesFrom | ( | const FILEPATH & | SourcePath, | |
| bool | RecurseSubDirectories = true | |||
| ) | const |
Update files from the source path to 'this' if the source file is of a later date.
If the directory referenced by 'this' does not exist, it will be created.
| SourcePath | Source directory to update files from | |
| RecurseSubDirectories | Update files from subdirectories also |
1.6.1