cee::FileSystem Class Reference

Static class containing file system utility functions. More...

Static Public Member Functions

static Str fromNativeSeparators (const Str &path)
 Converts path from using native separators to always use '/' as separator. More...
 
static Str toNativeSeparators (const Str &path)
 Returns path with separators that are appropriate for the underlying operating system. More...
 
static Str addTrailingSeparator (const Str &path)
 Adds a trailing separator to the input path if one isn't already present. More...
 
static Str removeTrailingSeparator (const Str &path)
 Returns path with any trailing separators removed. More...
 
static Str fileName (const Str &path)
 Returns the file name component of the path. More...
 
static Str extension (const Str &path)
 Returns the file extension, including the leading '.'. More...
 
static Str parentPath (const Str &path)
 Returns the parent path of the specified input path. More...
 
static Str makeAbsolute (const Str &path)
 Convert a relative path to an absolute path. More...
 
static Str currentPath ()
 Returns the full path of the current working directory. More...
 
static bool pathExists (const Str &pathName)
 Checks whether the specified file or directory exists. More...
 
static bool fileExists (const Str &fileName)
 Returns true if the specified file exists. More...
 
static bool directoryExists (const Str &dirName)
 Returns true if the specified directory exists. More...
 
static bool createDirectory (const Str &dirName)
 Creates a directory. More...
 
static bool createDirectoryTree (const Str &dirPath)
 Creates the directory path dirPath. More...
 
static bool copyFile (const Str &fromFileName, const Str &toFileName)
 Copies a file. More...
 
static bool deleteFile (const Str &fileName)
 Deletes a file. More...
 
static bool deleteDirectory (const Str &dirName)
 Deletes an empty directory. More...
 
static bool deleteAllFilesInDirectory (const Str &dirName)
 Deletes all files within the specified directory. More...
 
static bool deleteDirectoryRecursive (const Str &dirName)
 Deletes a directory and all its contents recursively. More...
 
static bool getDirectoryContents (const Str &dirName, std::vector< Str > *fileNameArr, std::vector< Str > *dirNameArr)
 Gets all files and sub-directories in the specified directory. More...
 
static std::vector< StrgetAllFilesInDirectory (const Str &dirName)
 Gets all files in the specified directory. More...
 
static std::vector< StrfindFilesInDirectory (const Str &dirName, const Str &filePattern)
 Returns all files matching filePattern in the specified directory. More...
 
static uint64_t fileSize (const Str &fileName)
 Returns the size of the given file in bytes. More...
 
static unsigned int fileContentsCrc (const Str &fileName, uint64_t maxBytesToRead)
 Returns the computed CRC of the contents of the given file. More...
 

Detailed Description

Static class containing file system utility functions.

Member Function Documentation

Str cee::FileSystem::addTrailingSeparator ( const Str path)
static

Adds a trailing separator to the input path if one isn't already present.

bool cee::FileSystem::copyFile ( const Str fromFileName,
const Str toFileName 
)
static

Copies a file.

bool cee::FileSystem::createDirectory ( const Str dirName)
static

Creates a directory.

Creates only one new directory per call, so only the last component of dirName can name a new directory.

If the directory already exists when this function is called, it will return false.

bool cee::FileSystem::createDirectoryTree ( const Str dirPath)
static

Creates the directory path dirPath.

The function will try to create all parent directories necessary to create the directory.

Returns true if successful or if the path already exists, otherwise returns false.

Str cee::FileSystem::currentPath ( )
static

Returns the full path of the current working directory.

bool cee::FileSystem::deleteAllFilesInDirectory ( const Str dirName)
static

Deletes all files within the specified directory.

bool cee::FileSystem::deleteDirectory ( const Str dirName)
static

Deletes an empty directory.

The directory must be empty, and it must not be the current working directory or the root directory.

bool cee::FileSystem::deleteDirectoryRecursive ( const Str dirName)
static

Deletes a directory and all its contents recursively.

bool cee::FileSystem::deleteFile ( const Str fileName)
static

Deletes a file.

bool cee::FileSystem::directoryExists ( const Str dirName)
static

Returns true if the specified directory exists.

Str cee::FileSystem::extension ( const Str path)
static

Returns the file extension, including the leading '.'.

unsigned int cee::FileSystem::fileContentsCrc ( const Str fileName,
uint64_t  maxBytesToRead 
)
static

Returns the computed CRC of the contents of the given file.

If maxBytesToRead > 0, only the first maxBytesToRead bytes of the file will be used.

bool cee::FileSystem::fileExists ( const Str fileName)
static

Returns true if the specified file exists.

Str cee::FileSystem::fileName ( const Str path)
static

Returns the file name component of the path.

The returned file name will include the file extension

uint64_t cee::FileSystem::fileSize ( const Str fileName)
static

Returns the size of the given file in bytes.

std::vector< cee::Str > cee::FileSystem::findFilesInDirectory ( const Str dirName,
const Str filePattern 
)
static

Returns all files matching filePattern in the specified directory.

Str cee::FileSystem::fromNativeSeparators ( const Str path)
static

Converts path from using native separators to always use '/' as separator.

std::vector< cee::Str > cee::FileSystem::getAllFilesInDirectory ( const Str dirName)
static

Gets all files in the specified directory.

bool cee::FileSystem::getDirectoryContents ( const Str dirName,
std::vector< Str > *  fileNameArr,
std::vector< Str > *  dirNameArr 
)
static

Gets all files and sub-directories in the specified directory.

cee::Str cee::FileSystem::makeAbsolute ( const Str path)
static

Convert a relative path to an absolute path.

Str cee::FileSystem::parentPath ( const Str path)
static

Returns the parent path of the specified input path.

bool cee::FileSystem::pathExists ( const Str pathName)
static

Checks whether the specified file or directory exists.

Str cee::FileSystem::removeTrailingSeparator ( const Str path)
static

Returns path with any trailing separators removed.

Str cee::FileSystem::toNativeSeparators ( const Str path)
static

Returns path with separators that are appropriate for the underlying operating system.