FileUtils
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_FILEUTILS
#define OSGDB_FILEUTILS 1
#include <osgDB/Registry>
#include <vector>
#include <deque>
#include <string>
#include <stdio.h>
namespace osgDB {
extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode);
extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath );
extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath );
extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void );
extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory );
extern OSGDB_EXPORT bool fileExists(const std::string& filename);
enum FileType
{
FILE_NOT_FOUND,
REGULAR_FILE,
DIRECTORY
};
extern OSGDB_EXPORT FileType fileType(const std::string& filename);
extern OSGDB_EXPORT std::string findFileInPath(const std::string& filename, const FilePathList& filePath,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
extern OSGDB_EXPORT std::string findFileInDirectory(const std::string& fileName,const std::string& dirName,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
typedef std::vector<std::string> DirectoryContents;
extern OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string& dirName);
extern OSGDB_EXPORT DirectoryContents getSortedDirectoryContents(const std::string& dirName);
extern OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string& filename);
enum CopyFileResult
{
COPY_FILE_OK,
COPY_FILE_SOURCE_EQUALS_DESTINATION,
COPY_FILE_BAD_ARGUMENT,
COPY_FILE_SOURCE_MISSING,
COPY_FILE_SOURCE_NOT_OPENED,
COPY_FILE_DESTINATION_NOT_OPENED,
COPY_FILE_READ_ERROR,
COPY_FILE_WRITE_ERROR
};
extern OSGDB_EXPORT CopyFileResult copyFile(const std::string & source, const std::string & destination);
inline void setDataFilePathList(const FilePathList& filepath) { osgDB::Registry::instance()->setDataFilePathList(filepath); }
inline void setDataFilePathList(const std::string& paths) { osgDB::Registry::instance()->setDataFilePathList(paths); }
inline FilePathList& getDataFilePathList() { return osgDB::Registry::instance()->getDataFilePathList(); }
extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,const Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
inline void setLibraryFilePathList(const FilePathList& filepaths) { osgDB::Registry::instance()->setLibraryFilePathList(filepaths); }
inline void setLibraryFilePathList(const std::string& paths) { osgDB::Registry::instance()->setLibraryFilePathList(paths); }
inline FilePathList& getLibraryFilePathList() { return osgDB::Registry::instance()->getLibraryFilePathList(); }
extern OSGDB_EXPORT std::string findLibraryFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
extern OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath);
extern OSGDB_EXPORT bool containsCurrentWorkingDirectoryReference(const FilePathList& paths);
extern OSGDB_EXPORT void appendPlatformSpecificLibraryFilePaths(FilePathList& filepath);
extern OSGDB_EXPORT void appendPlatformSpecificResourceFilePaths(FilePathList& filepath);
} // namespace osgDB
#endif
osgDB::Options
Definition Options:30
osgDB::Registry::getLibraryFilePathList
FilePathList & getLibraryFilePathList()
Definition osgDB/Registry:423
osgDB::Registry::setDataFilePathList
void setDataFilePathList(const FilePathList &filepath)
Definition osgDB/Registry:401
osgDB::Registry::getDataFilePathList
FilePathList & getDataFilePathList()
Definition osgDB/Registry:407
osgDB::Registry::instance
static Registry * instance(bool erase=false)
osgDB::Registry::setLibraryFilePathList
void setLibraryFilePathList(const FilePathList &filepath)
Definition osgDB/Registry:417
osgDB
Definition Archive:24
osgDB::getSortedDirectoryContents
OSGDB_EXPORT DirectoryContents getSortedDirectoryContents(const std::string &dirName)
osgDB::copyFile
OSGDB_EXPORT CopyFileResult copyFile(const std::string &source, const std::string &destination)
osgDB::CopyFileResult
CopyFileResult
Definition FileUtils:88
osgDB::COPY_FILE_SOURCE_NOT_OPENED
@ COPY_FILE_SOURCE_NOT_OPENED
Definition FileUtils:93
osgDB::COPY_FILE_OK
@ COPY_FILE_OK
Definition FileUtils:89
osgDB::COPY_FILE_SOURCE_MISSING
@ COPY_FILE_SOURCE_MISSING
Definition FileUtils:92
osgDB::COPY_FILE_WRITE_ERROR
@ COPY_FILE_WRITE_ERROR
Definition FileUtils:96
osgDB::COPY_FILE_DESTINATION_NOT_OPENED
@ COPY_FILE_DESTINATION_NOT_OPENED
Definition FileUtils:94
osgDB::COPY_FILE_READ_ERROR
@ COPY_FILE_READ_ERROR
Definition FileUtils:95
osgDB::COPY_FILE_SOURCE_EQUALS_DESTINATION
@ COPY_FILE_SOURCE_EQUALS_DESTINATION
Definition FileUtils:90
osgDB::COPY_FILE_BAD_ARGUMENT
@ COPY_FILE_BAD_ARGUMENT
Definition FileUtils:91
osgDB::findLibraryFile
OSGDB_EXPORT std::string findLibraryFile(const std::string &filename, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
osgDB::findFileInPath
OSGDB_EXPORT std::string findFileInPath(const std::string &filename, const FilePathList &filePath, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
osgDB::DirectoryContents
std::vector< std::string > DirectoryContents
Definition FileUtils:67
osgDB::expandWildcardsInFilename
OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string &filename)
osgDB::convertStringPathIntoFilePathList
OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string &paths, FilePathList &filepath)
osgDB::getDirectoryContents
OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string &dirName)
osgDB::FilePathList
std::deque< std::string > FilePathList
Definition osgDB/Callbacks:28
osgDB::appendPlatformSpecificResourceFilePaths
OSGDB_EXPORT void appendPlatformSpecificResourceFilePaths(FilePathList &filepath)
osgDB::setDataFilePathList
void setDataFilePathList(const FilePathList &filepath)
Definition FileUtils:107
osgDB::findFileInDirectory
OSGDB_EXPORT std::string findFileInDirectory(const std::string &fileName, const std::string &dirName, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
osgDB::FileType
FileType
Definition FileUtils:47
osgDB::FILE_NOT_FOUND
@ FILE_NOT_FOUND
Definition FileUtils:48
osgDB::REGULAR_FILE
@ REGULAR_FILE
Definition FileUtils:49
osgDB::DIRECTORY
@ DIRECTORY
Definition FileUtils:50
osgDB::fopen
OSGDB_EXPORT FILE * fopen(const char *filename, const char *mode)
osgDB::fileExists
OSGDB_EXPORT bool fileExists(const std::string &filename)
osgDB::makeDirectoryForFile
OSGDB_EXPORT bool makeDirectoryForFile(const std::string &filePath)
osgDB::setLibraryFilePathList
void setLibraryFilePathList(const FilePathList &filepaths)
Definition FileUtils:123
osgDB::makeDirectory
OSGDB_EXPORT bool makeDirectory(const std::string &directoryPath)
osgDB::findDataFile
OSGDB_EXPORT std::string findDataFile(const std::string &filename, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
osgDB::getLibraryFilePathList
FilePathList & getLibraryFilePathList()
Definition FileUtils:127
osgDB::CaseSensitivity
CaseSensitivity
Definition osgDB/Callbacks:31
osgDB::CASE_SENSITIVE
@ CASE_SENSITIVE
Definition osgDB/Callbacks:32
osgDB::fileType
OSGDB_EXPORT FileType fileType(const std::string &filename)
osgDB::appendPlatformSpecificLibraryFilePaths
OSGDB_EXPORT void appendPlatformSpecificLibraryFilePaths(FilePathList &filepath)
osgDB::setCurrentWorkingDirectory
OSGDB_EXPORT bool setCurrentWorkingDirectory(const std::string &newCurrentWorkingDirectory)
osgDB::getDataFilePathList
FilePathList & getDataFilePathList()
Definition FileUtils:111
osgDB::containsCurrentWorkingDirectoryReference
OSGDB_EXPORT bool containsCurrentWorkingDirectoryReference(const FilePathList &paths)
osgDB::getCurrentWorkingDirectory
OSGDB_EXPORT std::string getCurrentWorkingDirectory(void)
OSGDB_EXPORT
#define OSGDB_EXPORT
Definition osgDB/Export:39
Registry