tsc_Directory

Description

This class performs filesystem directory functions.  Most methods indicate success or failure by a boolean return value, and the GetLastError method will give more information or contain zero if the last operation succeded.

Note that because this API was originally designed to work with Windows CE, there is no concept of a current directory, and relative paths will fail to work if they are applied to the filesystem. Trimble Access always uses full path names.

All methods accept and expand Survey Core path macros of the form $(name).  See the tsc_Path class for details.

Member functions of the same name as the .NET Directory class equivalents perform similarly.

Member functions

static unsigned int GetLastError ();
This method returns the last error from any of the functions in this class.  It does not reflect the result of methods in any other class or API.  The returned value is zero if no error occurred, or a Windows error number, obtained from the Windows GetLastError() API call.

static tsc_StringList GetDirectories (const char* folderPath);
Returns a list of all directories within the named directory.  It is not recursive, and all returned paths are absolute. eg:
    tsc_StringList allJobDirs = tsc_Directory::GetDirectories("$(ProjectRootDir)");

static tsc_StringList GetFiles (const char* folderPath, const char* searchMask);
static tsc_StringList GetFiles (const char* folderPathWithSearchMask);
Returns a list of all the files in the directory specified in folderPath or folderPathWithSearchMask, that match the mask.  The returned paths contain full directory information (ie, they are absolute).

For example, either of the following will return a list of all job files in the same directory as the current job:
    tsc_StringList jobs = tsc_Directory::GetFiles ("$(ProjectRootDir)\$(Project)\*.job");
or
    tsc_StringList jobs = tsc_Directory::GetFiles ("$(ProjectRootDir)\$(Project)", "*.job");

static bool Create (const char* folderPath);
Creates a directory.  Any directories within the path that do not exist are also created.

static bool Exists (const char* folderPath);
Tests if the given directory exists.

static bool Empty (const char* folderPath);
Tests if a given directory is empty of subdirectories and files.      

static bool DeleteEmpty (const char* folderPath);
Deletes the specified directory if it is empty.  If it contains files or directories, an error occurs.

static bool DeleteRecursive (const char* path);
Deletes the specified directory, including all files and directories under it.