|
TrueReality
v0.1.1912
|
Singleton class implementing basic file operations. More...
#include <FileUtils.h>


Public Member Functions | |
| std::string | RunCommand (const char *cmd) |
| Runs a command on the console, and returns the console printout in a form of a string. More... | |
| std::string | RunCommand (const std::string cmd) |
| Runs a command on the console, and returns the console printout in a form of a string. More... | |
| bool | FileExists (const std::string &strFile, bool caseInsensitive=false) const |
| Queries if a given file exists. More... | |
| void | FileCopy (const std::string &strSrc, const std::string &strDest, bool bOverwrite) const |
| Copys a file. More... | |
| void | FileMove (const std::string &strSrc, const std::string &strDest, bool bOverwrite) const |
| Moves a file. More... | |
| void | FileDelete (const std::string &strFile) const |
| Deletes the given file. More... | |
| const struct FileInfo | GetFileInfo (const std::string &strFile, bool caseInsensitive=false) const |
| void | CleanupFileString (std::string &strFileOrDir) const |
| Ensure that the passed in string is fit for use as a file or dir string. More... | |
| bool | IsAbsolutePath (std::string strFileOrDir) const |
| Query whether a given string is an absolute path or not. More... | |
| void | MakeDirectoryEX (std::string strDir) |
| A more powerful version of the standard mkdir. More... | |
| void | ChangeDirectory (const std::string &path) |
| Changes the current directory to the one given in "path." This will clear the stack of directories that is set by pushDirectory and popDirectory. More... | |
| const std::string & | CurrentDirectory () const |
| Current directory. More... | |
| void | PushDirectory (const std::string &path) |
| Changes the current directory to the one given in "path" and adds the previous current directory to an internal stack so it can be returned to via popDirectory. More... | |
| void | PopDirectory () |
| sets the current directory to the last directory on the stack. More... | |
| std::string | GetAbsolutePath (const std::string &relativePath, bool removeFinalFile=false) const |
| Converts a relative path to an absolute path. More... | |
| DirectoryContents | DirGetFiles (const std::string &path, const FileExtensionList &extensions=FileExtensionList()) const |
| Note: throws exceptions of type trUtil::Exception. More... | |
| DirectoryContents | DirGetSubs (const std::string &path) const |
| Dir get subs. More... | |
| void | DirCopy (const std::string &srcPath, const std::string &destPath, bool bOverwrite, bool copyContentsOnly=false) const |
| Copys an entire directory. More... | |
| bool | DirDelete (const std::string &strDir, bool bRecursive) |
| Deletes a directory. More... | |
| void | MakeDirectory (const std::string &strDir) const |
| creates a new directory from a path. More... | |
| bool | DirExists (const std::string &strDir, bool caseInsensitive=false) const |
| Queries if a given dir exists. More... | |
| std::string | RelativePath (const std::string &absolutePath, const std::string &file) const |
| Helper function that returns the relative path between absolutePath and file. More... | |
| bool | IsSameFile (const std::string &file1, const std::string &file2) const |
| It is possible for two different path strings to point at the same file on disk. More... | |
| osg::Object * | ReadObject (const std::string &filename, osgDB::ReaderWriter::Options *options=NULL) |
| Reads an object. More... | |
| osg::Node * | ReadNode (const std::string &filename, osgDB::ReaderWriter::Options *options=NULL) |
| Reads a node. More... | |
| osgDB::ArchiveExtended * | FindArchive (const std::string &archiveFileName) const |
| Used to search for archives by filename. More... | |
Static Public Member Functions | |
| static FileUtils & | GetInstance () |
| Character separating the parts of a file path. More... | |
| static std::string | ConcatPaths (const std::string &left, const std::string &right) |
| Concatenates two paths adding a path separator in between if necessary. More... | |
Static Public Attributes | |
| static const char | PATH_SEPARATOR = '/' |
Private Member Functions | |
| FileUtils () | |
| Default constructor. More... | |
| virtual | ~FileUtils () |
| Destructor. More... | |
| void | ChangeDirectoryInternal (const std::string &path) |
| Change directory internal. More... | |
| void | InternalDirCopy (const std::string &srcPath, const std::string &destPath, bool bOverwrite) const |
| Internal dir copy. More... | |
| void | RecursDeleteDir (bool bRecursive) |
| Recurs delete dir. More... | |
| bool | SplitArchiveFilename (const std::string &fullFilename, std::string &archiveFilename, std::string &fileInArchive) const |
| Splits a filename for a file within an archive into two parts, the archive filename and the actual filename relative to the archive root. More... | |
| void | DirGetFilesInArchive (const osgDB::ArchiveExtended &a, const std::string &path, DirectoryContents &result) const |
| Internal function used to find files within an archive subdirectory. More... | |
| FileType | GetFileTypeForFileInArchive (const osgDB::ArchiveExtended &a, const std::string &path) const |
| Gets file type for file in archive. More... | |
| FileInfo | GetFileInfoForFileInArchive (const osgDB::ArchiveExtended &a, const std::string &path) const |
| Gets file information for file in archive. More... | |
| FileType | GetFileTypeFromOSGDBFileType (osgDB::FileType ft) const |
| Gets file type from osgdb file type. More... | |
| bool | ContainsArchiveExtension (const std::string &path) const |
| Query if 'path' contains archive extension. More... | |
| std::string | ArchiveRelativeToAbsolute (const std::string &relativeFile) const |
| Archive relative to absolute. More... | |
| const struct FileInfo | GetFileInfo_Internal (const std::string &strFile, bool caseInsensitive) const |
| bool | IsSameFile_Internal (const std::string &file1, const std::string &file2) const |
| Query if 'file1' is same file internal. More... | |
Private Attributes | |
| trUtil::Logging::Log * | mLogger |
| std::string | mCurrentDirectory |
| std::vector< std::string > | mStackOfDirectories |
Static Private Attributes | |
| static const int | PATH_BUFFER_SIZE = 1024 |
| Size of the path buffer. More... | |
| static osg::ref_ptr< FileUtils > | mInstance |
Singleton class implementing basic file operations.
Definition at line 125 of file FileUtils.h.
|
private |
Default constructor.
Definition at line 1498 of file FileUtils.cpp.
References ChangeDirectory(), trUtil::Logging::Log::GetInstance(), and mLogger.

|
privatevirtual |
Destructor.
Definition at line 1509 of file FileUtils.cpp.
|
private |
Archive relative to absolute.
| relativeFile | The relative file. |
Definition at line 478 of file FileUtils.cpp.
References CleanupFileString(), mCurrentDirectory, and trUtil::StringUtils::StringTokenizer< Pred >::tokenize().
Referenced by ChangeDirectory(), DirGetFiles(), FindArchive(), GetFileInfo(), IsSameFile(), ReadNode(), and ReadObject().


| void trUtil::FileUtils::ChangeDirectory | ( | const std::string & | path | ) |
Changes the current directory to the one given in "path." This will clear the stack of directories that is set by pushDirectory and popDirectory.
If this call fails, the stack will not be cleared.
| path | The path to the new directory. |
| trUtil::FileNotFoundException | if the path does not exist. |
Definition at line 707 of file FileUtils.cpp.
References ArchiveRelativeToAbsolute(), ChangeDirectoryInternal(), CleanupFileString(), ContainsArchiveExtension(), IsAbsolutePath(), mCurrentDirectory, and mStackOfDirectories.
Referenced by FileUtils().


|
private |
Change directory internal.
| path | Full pathname of the file. |
Definition at line 740 of file FileUtils.cpp.
References trUtil::DIRECTORY, trUtil::FileInfo::fileType, FindArchive(), GetFileInfoForFileInArchive(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), mCurrentDirectory, mLogger, and SplitArchiveFilename().
Referenced by ChangeDirectory(), PopDirectory(), PushDirectory(), and RecursDeleteDir().


| void trUtil::FileUtils::CleanupFileString | ( | std::string & | strFileOrDir | ) | const |
Ensure that the passed in string is fit for use as a file or dir string.
In our case we want all separators to be the '/' character and we do not want a separator at the end.
| [in,out] | strFileOrDir | The string to cleanup. |
Definition at line 601 of file FileUtils.cpp.
References PATH_SEPARATOR.
Referenced by ArchiveRelativeToAbsolute(), ChangeDirectory(), GetFileInfo(), IsAbsolutePath(), MakeDirectoryEX(), and SplitArchiveFilename().

|
static |
Concatenates two paths adding a path separator in between if necessary.
| left | The left. |
| right | The right. |
Definition at line 1485 of file FileUtils.cpp.
|
private |
Query if 'path' contains archive extension.
| path | Full pathname of the file. |
Definition at line 1680 of file FileUtils.cpp.
Referenced by ChangeDirectory(), and GetFileInfo().

| const std::string & trUtil::FileUtils::CurrentDirectory | ( | ) | const |
Current directory.
Definition at line 734 of file FileUtils.cpp.
References mCurrentDirectory.
| void trUtil::FileUtils::DirCopy | ( | const std::string & | srcPath, |
| const std::string & | destPath, | ||
| bool | bOverwrite, | ||
| bool | copyContentsOnly = false |
||
| ) | const |
Copys an entire directory.
If destPath exists, then a subdirectory will be created in destPath with the same name as srcPath unless copyContentsOnly is true, in which case the contents of srcPath will be copied into destPath. If destPath does not exist, destPath will be created if the parent exists and the contents of srcPath will be copied to destPath whether copyContentsOnly is true or false.
| trUtil::FileNotFoundException | if the source file is not found. |
| trUtil::IOException | if an error occurs copying the data or bOverwrite was false and a destination file exists. |
| srcPath | the source directory to copy. |
| destPath | the destination directory. |
| bOverwrite | true if this call should overwrite the destination file if it exists. |
| copyContentsOnly | (Optional) true if the contents of srcPath should be copied into destPath rather than create a subdirectory. |
Definition at line 1046 of file FileUtils.cpp.
References DirExists(), trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileType, GetAbsolutePath(), GetFileInfo(), InternalDirCopy(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), MakeDirectory(), mLogger, PATH_SEPARATOR, and trUtil::REGULAR_FILE.

| bool trUtil::FileUtils::DirDelete | ( | const std::string & | strDir, |
| bool | bRecursive | ||
| ) |
Deletes a directory.
If bRecursive is true, the directory and all it's contents will be removed. If it's false, the call will fail unless the directory is empty.
| trUtil::FileNotFoundException | if the path does not exist. |
| trUtil::IOException | if an error occurs deleteting the directory. |
| strDir | The path of the directory to delete. |
| bRecursive | true if the directory should be deleted recursively. |
Definition at line 1139 of file FileUtils.cpp.
References DirExists(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Exception::LogException(), trUtil::Logging::Log::LogMessage(), mLogger, PopDirectory(), PushDirectory(), and RecursDeleteDir().

| bool trUtil::FileUtils::DirExists | ( | const std::string & | strDir, |
| bool | caseInsensitive = false |
||
| ) | const |
Queries if a given dir exists.
| strDir | The directory to check. |
| caseInsensitive | (Optional) false for native, true for forced case insensitivity on platforms that normally are sensitive. |
Definition at line 1247 of file FileUtils.cpp.
References trUtil::DIRECTORY, trUtil::FileInfo::fileType, and GetFileInfo().
Referenced by DirCopy(), DirDelete(), MakeDirectory(), and MakeDirectoryEX().


| DirectoryContents trUtil::FileUtils::DirGetFiles | ( | const std::string & | path, |
| const FileExtensionList & | extensions = FileExtensionList() |
||
| ) | const |
Note: throws exceptions of type trUtil::Exception.
| trUtil::FileNotFoundException | if the path does not exist. |
| trUtil::IOException | if the path is not an actual directory. |
| path | the path to the directory to list the contents of. |
| extensions | (Optional) Optional list of file extensions to filter on, including the "dot". (e.g., ".txt", ".xml") |
Definition at line 901 of file FileUtils.cpp.
References trUtil::ARCHIVE, ArchiveRelativeToAbsolute(), DirGetFilesInArchive(), trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileType, FindArchive(), trUtil::getFileExtensionIncludingDot(), GetFileInfo(), IsAbsolutePath(), trUtil::FileInfo::isInArchive, trUtil::REGULAR_FILE, SplitArchiveFilename(), and trUtil::StringUtils::StrCompare().
Referenced by DirGetSubs(), InternalDirCopy(), and RecursDeleteDir().


|
private |
Internal function used to find files within an archive subdirectory.
| a | The osgDB::ArchiveExtended to process. | |
| path | Full pathname of the file. | |
| [in,out] | result | The result. |
Definition at line 1569 of file FileUtils.cpp.
References SplitArchiveFilename().
Referenced by DirGetFiles().


| DirectoryContents trUtil::FileUtils::DirGetSubs | ( | const std::string & | path | ) | const |
Dir get subs.
| trUtil::FileNotFoundException | if the path does not exist. |
| path | the path to the directory to get the subdirectories for. |
Definition at line 977 of file FileUtils.cpp.
References trUtil::DIRECTORY, DirGetFiles(), trUtil::FileInfo::fileType, GetFileInfo(), and PATH_SEPARATOR.

| void trUtil::FileUtils::FileCopy | ( | const std::string & | strSrc, |
| const std::string & | strDest, | ||
| bool | bOverwrite | ||
| ) | const |
Copys a file.
| trUtil::FileNotFoundException | if the source file is not found. |
| trUtil::IOException | if an error occurs copying the data or bOverwrite was false and the destination file exists. |
| strSrc | The path to the source file. |
| strDest | The path to the destination file or directory. |
| bOverwrite | true if this call should overwrite the destination file if it exists. |
Definition at line 223 of file FileUtils.cpp.
References trUtil::DIRECTORY, FileExists(), trUtil::FileInfo::fileType, GetFileInfo(), trUtil::Logging::Log::IsLevelEnabled(), IsSameFile(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), mLogger, and PATH_SEPARATOR.
Referenced by FileMove(), and InternalDirCopy().


| void trUtil::FileUtils::FileDelete | ( | const std::string & | strFile | ) | const |
Deletes the given file.
| trUtil::IOException | if an error occurs deleting the data. |
| strFile | the path to the file to delete. |
Definition at line 417 of file FileUtils.cpp.
References trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileType, GetFileInfo(), and trUtil::REGULAR_FILE.

| bool trUtil::FileUtils::FileExists | ( | const std::string & | strFile, |
| bool | caseInsensitive = false |
||
| ) | const |
Queries if a given file exists.
| strFile | the path to the file to check. |
| caseInsensitive | (Optional) false for native, true for forced case insensitivity on platforms that normally are sensitive. |
Definition at line 217 of file FileUtils.cpp.
References trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileType, and GetFileInfo().
Referenced by FileCopy(), and trUtil::JSON::File::FileExists().


| void trUtil::FileUtils::FileMove | ( | const std::string & | strSrc, |
| const std::string & | strDest, | ||
| bool | bOverwrite | ||
| ) | const |
Moves a file.
This call will attempt to move the file without moving the data, but if it can't, the file will first be copied then the source file will be removed.
| trUtil::FileNotFoundException | if the source file is not found. |
| trUtil::IOException | if an error occurs moving the data or bOverwrite was false and the destination file exists. |
| strSrc | The path to the source file. |
| strDest | The path to the destintion file or directory. |
| bOverwrite | true if this call should overwrite the destination file if it exists. |
Definition at line 348 of file FileUtils.cpp.
References trUtil::DIRECTORY, trUtil::FILE_NOT_FOUND, FileCopy(), trUtil::FileInfo::fileType, GetFileInfo(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), mLogger, PATH_SEPARATOR, and trUtil::REGULAR_FILE.

| osgDB::ArchiveExtended * trUtil::FileUtils::FindArchive | ( | const std::string & | archiveFileName | ) | const |
Used to search for archives by filename.
| archiveFileName | Filename of the archive file. |
Definition at line 1614 of file FileUtils.cpp.
References ArchiveRelativeToAbsolute(), trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileType, GetFileInfo(), IsAbsolutePath(), and SplitArchiveFilename().
Referenced by ChangeDirectoryInternal(), DirGetFiles(), GetFileInfo_Internal(), ReadNode(), and ReadObject().


| std::string trUtil::FileUtils::GetAbsolutePath | ( | const std::string & | relativePath, |
| bool | removeFinalFile = false |
||
| ) | const |
Converts a relative path to an absolute path.
| trUtil::FileNotFoundException | if the path does not exist. |
| relativePath | the relative path to convert to absolute. |
| removeFinalFile | (Optional) If this refers to a file, then remove the final file in the result. |
Definition at line 833 of file FileUtils.cpp.
References trUtil::ARCHIVE, trUtil::FileInfo::baseName, trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileType, GetFileInfo(), trUtil::DirectoryPush::GetSucceeded(), trUtil::FileInfo::isInArchive, mCurrentDirectory, trUtil::FileInfo::path, PATH_SEPARATOR, and trUtil::REGULAR_FILE.
Referenced by DirCopy(), and IsSameFile().


| const struct FileInfo trUtil::FileUtils::GetFileInfo | ( | const std::string & | strFile, |
| bool | caseInsensitive = false |
||
| ) | const |
Definition at line 441 of file FileUtils.cpp.
References ArchiveRelativeToAbsolute(), CleanupFileString(), ContainsArchiveExtension(), GetFileInfo_Internal(), IsAbsolutePath(), and mCurrentDirectory.
Referenced by DirCopy(), DirExists(), DirGetFiles(), DirGetSubs(), FileCopy(), FileDelete(), FileExists(), FileMove(), FindArchive(), trUtil::PathUtils::FindFile(), GetAbsolutePath(), InternalDirCopy(), IsSameFile(), MakeDirectory(), ReadNode(), ReadObject(), and RecursDeleteDir().


|
private |
Definition at line 519 of file FileUtils.cpp.
References trUtil::ARCHIVE, trUtil::FileInfo::baseName, trUtil::DIRECTORY, trUtil::FileInfo::extension, trUtil::FileInfo::extensionlessFileName, trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileName, trUtil::FileInfo::fileType, FindArchive(), GetFileInfoForFileInArchive(), trUtil::FileInfo::lastModified, trUtil::FileInfo::path, PATH_SEPARATOR, trUtil::REGULAR_FILE, S_ISDIR, trUtil::FileInfo::size, and SplitArchiveFilename().
Referenced by GetFileInfo().


|
private |
Gets file information for file in archive.
| a | The osgDB::ArchiveExtended to process. |
| path | Full pathname of the file. |
Definition at line 1581 of file FileUtils.cpp.
References trUtil::FileInfo::baseName, trUtil::FileInfo::extension, trUtil::FileInfo::extensionlessFileName, trUtil::FILE_NOT_FOUND, trUtil::FileInfo::fileName, trUtil::FileInfo::fileType, GetFileTypeFromOSGDBFileType(), trUtil::FileInfo::isInArchive, trUtil::FileInfo::lastModified, trUtil::FileInfo::path, and trUtil::FileInfo::size.
Referenced by ChangeDirectoryInternal(), and GetFileInfo_Internal().


|
private |
Gets file type for file in archive.
| a | The osgDB::ArchiveExtended to process. |
| path | Full pathname of the file. |
Definition at line 1562 of file FileUtils.cpp.
References GetFileTypeFromOSGDBFileType().

|
private |
Gets file type from osgdb file type.
| ft | The ft. |
Definition at line 1662 of file FileUtils.cpp.
References trUtil::DIRECTORY, trUtil::FILE_NOT_FOUND, and trUtil::REGULAR_FILE.
Referenced by GetFileInfoForFileInArchive(), and GetFileTypeForFileInArchive().

|
inlinestatic |
Character separating the parts of a file path.
Gets the instance.
Definition at line 137 of file FileUtils.h.
Referenced by trUtil::PathUtils::CreateDataPathTree(), trUtil::PathUtils::CreateUserDataPathTree(), trUtil::DirectoryPush::DirectoryPush(), trUtil::JSON::File::FileExists(), trUtil::PathUtils::FindFile(), trUtil::VersionUtil::GetCurrentCommitNum(), trUtil::Logging::LogWriterFile::OpenFile(), and trUtil::DirectoryPush::~DirectoryPush().

|
private |
Internal dir copy.
| srcPath | Full pathname of the source file. |
| destPath | Full pathname of the destination file. |
| bOverwrite | True to overwrite, false to preserve. |
Definition at line 995 of file FileUtils.cpp.
References trUtil::DIRECTORY, DirGetFiles(), trUtil::FILE_NOT_FOUND, FileCopy(), trUtil::FileInfo::fileType, GetFileInfo(), trUtil::Logging::Log::IsLevelEnabled(), LOG_WARNING, trUtil::Logging::Log::LogMessage(), MakeDirectory(), mLogger, PATH_SEPARATOR, and trUtil::REGULAR_FILE.
Referenced by DirCopy().


| bool trUtil::FileUtils::IsAbsolutePath | ( | std::string | strFileOrDir | ) | const |
Query whether a given string is an absolute path or not.
| strFileOrDir | The path to check. |
Definition at line 630 of file FileUtils.cpp.
References CleanupFileString().
Referenced by ChangeDirectory(), DirGetFiles(), FindArchive(), GetFileInfo(), IsSameFile(), ReadNode(), ReadObject(), and RelativePath().


| bool trUtil::FileUtils::IsSameFile | ( | const std::string & | file1, |
| const std::string & | file2 | ||
| ) | const |
It is possible for two different path strings to point at the same file on disk.
(Things like relative paths and filesystem links make this possible).
This function makes absolutely certain that the two files aren't the same by checking the inodes of the two files – preventing things like having the FileUtils::FileCopy accidentally blow away a file by copying it onto itself.
| file1 | – Path to first file. |
| file2 | – Path to second file. |
Definition at line 1318 of file FileUtils.cpp.
References ArchiveRelativeToAbsolute(), GetAbsolutePath(), GetFileInfo(), IsAbsolutePath(), trUtil::FileInfo::isInArchive, IsSameFile_Internal(), trUtil::FileInfo::path, and SplitArchiveFilename().
Referenced by FileCopy().


|
private |
Query if 'file1' is same file internal.
| file1 | The first file. |
| file2 | The second file. |
Definition at line 1380 of file FileUtils.cpp.
Referenced by IsSameFile().

| void trUtil::FileUtils::MakeDirectory | ( | const std::string & | strDir | ) | const |
creates a new directory from a path.
| trUtil::FileNotFoundException | if the parent path does not exist. |
| trUtil::IOException | if an error occurs creating the directory. |
| strDir | the directory to create. |
Definition at line 1219 of file FileUtils.cpp.
References trUtil::DIRECTORY, DirExists(), trUtil::FileInfo::fileType, GetFileInfo(), trUtil::iMakeDirectory(), and trUtil::REGULAR_FILE.
Referenced by DirCopy(), InternalDirCopy(), and MakeDirectoryEX().


| void trUtil::FileUtils::MakeDirectoryEX | ( | std::string | strDir | ) |
A more powerful version of the standard mkdir.
This function will check to see if the directory exists first and only create if needed. Also, it will recursively create all subdirectories needed to create the final directory in the passed in string.
| all | the exceptions that MakeDirectory throws. |
| strDir | The directory to create. |
Definition at line 651 of file FileUtils.cpp.
References CleanupFileString(), DirExists(), and MakeDirectory().
Referenced by trUtil::PathUtils::CreateDataPathTree(), trUtil::PathUtils::CreateUserDataPathTree(), and trUtil::Logging::LogWriterFile::OpenFile().


| void trUtil::FileUtils::PopDirectory | ( | ) |
sets the current directory to the last directory on the stack.
| trUtil::FileNotFoundException | if the previous directory no longer exists. |
Definition at line 816 of file FileUtils.cpp.
References ChangeDirectoryInternal(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), mLogger, and mStackOfDirectories.
Referenced by DirDelete(), and trUtil::DirectoryPush::~DirectoryPush().


| void trUtil::FileUtils::PushDirectory | ( | const std::string & | path | ) |
Changes the current directory to the one given in "path" and adds the previous current directory to an internal stack so it can be returned to via popDirectory.
If this call fails, the stack will not be changed.
| trUtil::FileNameFoundException | if the path does not exist. |
| path | The path to the new directory. |
Definition at line 801 of file FileUtils.cpp.
References ChangeDirectoryInternal(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), mCurrentDirectory, mLogger, and mStackOfDirectories.
Referenced by DirDelete(), and trUtil::DirectoryPush::DirectoryPush().


| osg::Node * trUtil::FileUtils::ReadNode | ( | const std::string & | filename, |
| osgDB::ReaderWriter::Options * | options = NULL |
||
| ) |
Reads a node.
| filename | Filename of the file. | |
| [in,out] | options | (Optional) If non-null, options for controlling the operation. |
Definition at line 1761 of file FileUtils.cpp.
References trUtil::ARCHIVE, ArchiveRelativeToAbsolute(), trUtil::FileInfo::fileType, FindArchive(), GetFileInfo(), IsAbsolutePath(), trUtil::FileInfo::isInArchive, and SplitArchiveFilename().

| osg::Object * trUtil::FileUtils::ReadObject | ( | const std::string & | filename, |
| osgDB::ReaderWriter::Options * | options = NULL |
||
| ) |
Reads an object.
| filename | Filename of the file. | |
| [in,out] | options | (Optional) If non-null, options for controlling the operation. |
Definition at line 1710 of file FileUtils.cpp.
References trUtil::ARCHIVE, ArchiveRelativeToAbsolute(), trUtil::FileInfo::fileType, FindArchive(), GetFileInfo(), IsAbsolutePath(), trUtil::FileInfo::isInArchive, trUtil::REGULAR_FILE, and SplitArchiveFilename().

|
private |
Recurs delete dir.
| bRecursive | True to process recursively, false to process locally only. |
Definition at line 1432 of file FileUtils.cpp.
References ChangeDirectoryInternal(), trUtil::DIRECTORY, DirGetFiles(), trUtil::FileInfo::fileType, GetFileInfo(), trUtil::Logging::Log::IsLevelEnabled(), LOG_DEBUG, trUtil::Logging::Log::LogMessage(), mCurrentDirectory, mLogger, PATH_SEPARATOR, and trUtil::REGULAR_FILE.
Referenced by DirDelete().


| std::string trUtil::FileUtils::RelativePath | ( | const std::string & | absolutePath, |
| const std::string & | file | ||
| ) | const |
Helper function that returns the relative path between absolutePath and file.
| absolutePath | The absolute path to search. |
| file | The absolute path to the file. |
Definition at line 1253 of file FileUtils.cpp.
References trUtil::GetPathRoot(), IsAbsolutePath(), PATH_SEPARATOR, and trUtil::StringUtils::StringTokenizer< Pred >::tokenize().

| std::string trUtil::FileUtils::RunCommand | ( | const char * | cmd | ) |
Runs a command on the console, and returns the console printout in a form of a string.
| cmd | The command. |
Definition at line 195 of file FileUtils.cpp.
Referenced by trUtil::VersionUtil::GetCurrentCommitNum(), and RunCommand().

| std::string trUtil::FileUtils::RunCommand | ( | const std::string | cmd | ) |
Runs a command on the console, and returns the console printout in a form of a string.
| cmd | The command. |
Definition at line 189 of file FileUtils.cpp.
References RunCommand().

|
private |
Splits a filename for a file within an archive into two parts, the archive filename and the actual filename relative to the archive root.
| fullFilename | Filename of the full file. | |
| [in,out] | archiveFilename | Filename of the archive file. |
| [in,out] | fileInArchive | The file in archive. |
Definition at line 1513 of file FileUtils.cpp.
References CleanupFileString().
Referenced by ChangeDirectoryInternal(), DirGetFiles(), DirGetFilesInArchive(), FindArchive(), GetFileInfo_Internal(), IsSameFile(), ReadNode(), and ReadObject().


|
private |
Definition at line 684 of file FileUtils.h.
Referenced by ArchiveRelativeToAbsolute(), ChangeDirectory(), ChangeDirectoryInternal(), CurrentDirectory(), GetAbsolutePath(), GetFileInfo(), PushDirectory(), and RecursDeleteDir().
|
staticprivate |
Definition at line 680 of file FileUtils.h.
|
private |
Definition at line 682 of file FileUtils.h.
Referenced by ChangeDirectoryInternal(), DirCopy(), DirDelete(), FileCopy(), FileMove(), FileUtils(), InternalDirCopy(), PopDirectory(), PushDirectory(), and RecursDeleteDir().
|
private |
Definition at line 685 of file FileUtils.h.
Referenced by ChangeDirectory(), PopDirectory(), and PushDirectory().
|
staticprivate |
Size of the path buffer.
Definition at line 532 of file FileUtils.h.
|
static |
Definition at line 128 of file FileUtils.h.
Referenced by CleanupFileString(), DirCopy(), DirGetSubs(), FileCopy(), FileMove(), trUtil::PathUtils::FindFile(), GetAbsolutePath(), GetFileInfo_Internal(), InternalDirCopy(), trUtil::Logging::LogWriterFile::OpenFile(), RecursDeleteDir(), and RelativePath().