![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
This class provides platform independent access to common file and directory related methods.
If you are not using the version of Visual Studio that MapLink was built with then may not be able to use the following methods from this class:
The issue is that FILE definition may be different between the C Runtimes.
Public Types | |
typedef void(* | FilenameCallback) (const TSLSimpleString &foundFile, const TSLSimpleString &directory, void *userData) |
typedef void(* | DirectoryCallback) (const TSLSimpleString &foundDirectory, void *userData) |
Static Public Member Functions | |
static bool | buildDirectory (TSLSimpleString &path, const char *baseDir, const char *subDir) |
static bool | createDirectory (const char *dirname) |
static bool | copyFile (const char *sourceFile, const char *destinationFile) |
static bool | composePathname (TSLSimpleString &fullPath, const char *directory, const char *basename, const char *extension) |
static bool | compareFilenames (const char *first, const char *second, const bool removeTrailingWhitespace=true) |
static bool | decomposePathname (const char *fullPath, TSLSimpleString &directory, TSLSimpleString &basename, TSLSimpleString &extension) |
static int | deleteFile (const char *filename) |
static int | deleteDirectory (const char *dirName) |
static bool | directoryExists (const char *dirname) |
static int | fileAccess (const char *path, int mode) |
static bool | fileExists (const char *filename) |
static bool | fileModificationTime (char const *filePath, TSLTimeType &lastModificationTime) |
static TSLFileLength | fileSize (const char *path) |
static int | fclose (FILE *stream) |
static FILE * | fopen (const char *filename, const char *mode) |
static TSLFileOffset | ftell (FILE *stream) |
static int | fseek (FILE *stream, TSLFileOffset offset, int origin) |
static TSLTextEncoding | legacyGetEncodingOverride () |
static void | legacySetEncodingOverride (TSLTextEncoding encoding) |
static bool | listDirectory (const char *directory, FilenameCallback filenameCallback, void *userData=NULL, const char *pattern="*") |
static bool | listSubDirectories (const char *directory, DirectoryCallback directoryCallback, void *userData=NULL, const char *pattern="*") |
static bool | rename (const char *oldName, const char *newName) |
typedef void(* TSLFileHelper::DirectoryCallback) (const TSLSimpleString &foundDirectory, void *userData) |
Function typedef.
This function typedef defines the signature of a function that the user can pass to the listSubDirectories() method.
Implementation:
The callback will be called for each directory found. The user should copy the directory string passed in.
foundDirectory | The full path of a sub-directory found in the requested directory. |
userData | The userData pointer that was passed to the listSubDirectories() method. |
typedef void(* TSLFileHelper::FilenameCallback) (const TSLSimpleString &foundFile, const TSLSimpleString &directory, void *userData) |
Function typedef.
This function typedef defines the signature of a function that the user can pass to the listDirectory() method.
Implementation:
The callback will be called for each file found. The user should copy the filename passed in and potentially the associated directory string too.
foundFile | The name of a file found in the directory passed to listDirectory(). This does not contain the directory path, just the filename. |
directory | The base directory passed to listDirectory(). |
userData | The userData pointer that was passed to the listDirectory() method. |
|
static |
Composes a full pathname from directory and subdirectory.
path | The returned full pathname |
baseDir | The base directory. |
subDir | The sub directory. |
|
static |
This method compares filenames.
The comparison is carried out against the full string in both parameters. So if a partial path is passed in it is assumed that the same partial path is passed in.
On windows it will be case-insensitive and on all other OS's it will be case sensitive.
The directory path separators will be correctly altered for the relevant platforms before comparison.
The filename's are not returned.
first | The first filename to compare. |
second | The second filename to compare. |
removeTrailingWhitespace | If true any trailing white space is removed before the comparison occurs. |
|
static |
composes a full pathname from directory, basename and extension components.
If particular components are not required then NULL may be passed as the appropriate parameter.
fullPath | The full path created from the other parameters. |
directory | The directory the file is contained in. |
basename | The first part of the filename. |
extension | The file extension. The '.' is not required. |
|
static |
Copies the specified source file to the given destination.
sourceFile | The full path to the source file to copy |
destinationFile | The full path including filename to where the file should be copied to. Any directories specified as part of the destination file path should already exist. |
|
static |
Creates specified directory.
dirname | The name of the directory to create. |
|
static |
This method decomposes the specified full pathname into directory, basename and extension components.
Arguments
fullPath : the full path to the filename.
directory : The directory containing the file.
basename : The base part of the filename.
extension : The extension of the filename. The '.' is not returned.
Returns True if successful, False otherwise.
|
static |
This recursive method deletes the current directory (and any directories and files below it).
dirName | the directory to delete |
|
static |
Deletes the specified file.
filename | the file to delete. |
|
static |
Checks to see if a directory exists.
dirname | directory path to check for exists of. |
|
static |
Calls the correct fclose on different platforms.
stream : a FILE* opened via TSLFileHelper::fopen
|
static |
This method checks the file access of the specified file. This is a simple access check.
This method calls _access under NT, access under X11. Determines the accessibility (read-only etc.) of the file passed.
path | path to check access rights too. |
mode | The mode of access to check for. |
The mode may be OR'd together. The values are defined below
|
static |
Checks to see if a file exists.
Returns True if exists, false otherwise.
|
static |
Queries the file for its last modification time.
filePath | filename and path to the file to query. |
lastModificationTime | The last modification time is returned in this parameter. |
|
static |
Determines the file size of the file passed.
path | the filename to query the size of. |
|
static |
Performs an open which is where possible to the underlying OS large file fopen.
You can use this for large and small files.
filename | the file to open |
mode | the mode to open the file (see the fopen manual page for your system). |
|
static |
fseek for large files (where the OS supports large files).
You can use this for large and small files.
stream | The FILE pointer returned by TSLFileHelper::fopen |
offset | The offset returned by a call to TSLFileHelper::ftell |
origin | The initial position |
The origin may be one of the following
|
static |
ftell for large file support (where the OS supports large files).
You can use this for large and small files.
stream : The FILE pointer returned by TSLFileHelper::fopen
|
static |
Get the legacy text encoding override.
If set, this override specifies the encoding of filenames passed to and from the TSLFileHelper.
This function is only for use with legacy applications, and will be removed in a future release.
Returns the legacy text encoding override.
|
static |
Set the legacy text encoding override. If set, this override specifies the encoding of filenames passed to and from TSLFileHelper.
This function is only for use with legacy applications, and will be removed in a future release. Applications are strongly discouraged from using this function as changing the value may cause errors to occur elsewhere in MapLink when working with Unicode filenames.
If an application changes the value in order to pass non-UTF8 strings to a method on this class, it must restore the original encoding (TSLTextEncodingUTF8) immediately after the method has returned to avoid errors occurring in other parts of MapLink.
This function is not thread safe.
encoding | The text encoding to use. |
|
static |
This method queries the contents of the specified directory and calls the user supplied callback for each item found.
directory | Directory to search. |
filenameCallback | Callback to call for each file found in the directory. |
userData | A pointer to user supplied data. This is passed to the user supplied callback. |
pattern | Search pattern. |
|
static |
This method queries the sub-directories of the specified directory and calls the user supplied callback for each item found.
directory | Directory to search. |
directoryCallback | Callback to call for each sub-directory found in the directory. |
userData | A pointer to user supplied data. This is passed to the user supplied callback. |
pattern | Search pattern. |
|
static |
Renames a file or directory.
The method renames the file or directory specified by oldName to the name given by newName. The old name must be the path of an existing file or directory. The new name must not be the name of an existing file or directory. You can use rename to move a file from one directory or device to another by giving a different path in the newName argument. However, you cannot use rename to move a directory. Directories can be renamed, but not moved.
oldName | The old name. |
newName | The new name. |