34 #include <osg/Referenced> 35 #include <osg/Version> 36 #include <osgDB/ReaderWriter> 37 #include <osgDB/FileUtils> 43 #if OPENSCENEGRAPH_MAJOR_VERSION < 3 46 class ArchiveExtended;
51 using ArchiveExtended = Archive;
104 FileUtilIOException(
const std::string& message,
const std::string& filename,
unsigned int linenum);
116 FileNotFoundException(
const std::string& message,
const std::string& filename,
unsigned int linenum);
139 if (mInstance == NULL)
155 std::string RunCommand(
const char* cmd);
166 std::string RunCommand(
const std::string cmd);
179 bool FileExists(
const std::string& strFile,
bool caseInsensitive =
false)
const;
195 void FileCopy(
const std::string& strSrc,
const std::string& strDest,
bool bOverwrite)
const;
212 void FileMove(
const std::string& strSrc,
const std::string& strDest,
bool bOverwrite)
const;
223 void FileDelete(
const std::string& strFile)
const;
239 const struct FileInfo GetFileInfo(const std::string& strFile, bool caseInsensitive = false) const;
251 void CleanupFileString(std::string &strFileOrDir) const;
263 bool IsAbsolutePath(std::string strFileOrDir) const;
279 void MakeDirectoryEX(std::string strDir);
296 void ChangeDirectory(const std::string& path);
305 const std::string& CurrentDirectory() const;
320 void PushDirectory(const std::string& path);
346 std::string GetAbsolutePath(const std::string& relativePath, bool removeFinalFile = false) const;
362 DirectoryContents DirGetFiles(const std::string& path, const FileExtensionList& extensions = FileExtensionList()) const;
398 void DirCopy(const std::string& srcPath, const std::string& destPath, bool bOverwrite, bool copyContentsOnly = false) const;
414 bool DirDelete(const std::string& strDir, bool bRecursive);
426 void MakeDirectory(const std::string& strDir) const;
439 bool DirExists(const std::string& strDir, bool caseInsensitive = false) const;
452 std::string RelativePath(const std::string& absolutePath, const std::string& file) const;
480 bool IsSameFile(const std::string& file1, const std::string& file2) const;
492 static std::string ConcatPaths(const std::string& left, const std::string& right);
504 osg::Object* ReadObject(const std::string& filename, osgDB::ReaderWriter::Options* options = NULL);
516 osg::Node* ReadNode(const std::string& filename, osgDB::ReaderWriter::Options* options = NULL);
527 osgDB::ArchiveExtended* FindArchive(const std::string& archiveFileName) const;
532 static const int PATH_BUFFER_SIZE = 1024;
555 void ChangeDirectoryInternal(const std::string& path);
566 void InternalDirCopy(const std::string& srcPath, const std::string& destPath, bool bOverwrite) const;
575 void RecursDeleteDir(bool bRecursive);
590 bool SplitArchiveFilename(const std::string& fullFilename, std::string& archiveFilename, std::string& fileInArchive) const;
601 void DirGetFilesInArchive(const osgDB::ArchiveExtended& a, const std::string& path, DirectoryContents& result) const;
613 FileType GetFileTypeForFileInArchive(const osgDB::ArchiveExtended& a, const std::string& path) const;
625 FileInfo GetFileInfoForFileInArchive(const osgDB::ArchiveExtended& a, const std::string& path) const;
636 FileType GetFileTypeFromOSGDBFileType(osgDB::FileType ft) const;
647 bool ContainsArchiveExtension(const std::string& path) const;
658 std::string ArchiveRelativeToAbsolute(const std::string& relativeFile) const;
665 const struct
FileInfo GetFileInfo_Internal(const std::string& strFile, bool caseInsensitive) const;
677 bool IsSameFile_Internal(const std::string& file1, const std::string& file2) const;
680 static osg::ref_ptr<FileUtils> mInstance;
684 std::string mCurrentDirectory;
685 std::vector<std::string> mStackOfDirectories;
731 const std::string& GetError();
745 bool operator()(
char c)
const {
return c ==
'/' || c ==
'\\' || c == FileUtils::PATH_SEPARATOR; }
Log class which the engine uses for all of its logging needs.
Exception for signaling file utility i/o errors.
A unary function created to have a compatibility to the old std::unary_function while still using c++...
This is the exception class used throughout the engine.
virtual ~FileUtilIOException()
Singleton class implementing basic file operations.
bool operator()(char c) const
std::string extensionlessFileName
the file name with extension
struct holding information about a file.
std::vector< std::string > DirectoryContents
virtual ~FileNotFoundException()
std::vector< std::string > FileExtensionList
Exception for signalling file not found errors.
FileType
Values that represent file types.
time_t lastModified
when the file was last modified.
size_t size
the size of the file in bytes.
FileType fileType
The enum value specifying the type of file.
A class that represents date time utility.
std::string path
the path to the file
static FileUtils & GetInstance()
Character separating the parts of a file path.
bool isInArchive
true if the specified file lives within an archive
Namespace that holds various utility classes for the engine.
std::string fileName
the file name with full path
std::string extension
the file extension
static const char PATH_SEPARATOR
Simple class to change directory where it automatically pop back out on destruction.
std::string baseName
the file name with extension