OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileUtils.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGDB_FILEUTILS
15 #define OSGDB_FILEUTILS 1
16 
17 #include <osgDB/Registry>
18 
19 #include <vector>
20 #include <deque>
21 #include <string>
22 #include <stdio.h>
23 
24 namespace osgDB {
25 
28 extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode);
29 
31 extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath );
32 
34 extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath );
35 
37 extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void );
38 
40 extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory );
41 
42 
44 extern OSGDB_EXPORT bool fileExists(const std::string& filename);
45 
47 {
51 };
52 
54 extern OSGDB_EXPORT FileType fileType(const std::string& filename);
55 
57 extern OSGDB_EXPORT std::string findFileInPath(const std::string& filename, const FilePathList& filePath,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
58 
64 extern OSGDB_EXPORT std::string findFileInDirectory(const std::string& fileName,const std::string& dirName,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
65 
67 typedef std::vector<std::string> DirectoryContents;
68 
72 extern OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string& dirName);
73 
77 extern OSGDB_EXPORT DirectoryContents getSortedDirectoryContents(const std::string& dirName);
78 
85 extern OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string& filename);
86 
87 namespace FileOpResult {
88  enum Value
89  {
90  OK,
98  };
99 }
100 
106 extern OSGDB_EXPORT FileOpResult::Value copyFile(const std::string & source, const std::string & destination);
107 
108 
109 
111 
112 inline void setDataFilePathList(const std::string& paths) { osgDB::Registry::instance()->setDataFilePathList(paths); }
113 
115 
119 extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
120 
124 extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,const Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
125 
127 
128 inline void setLibraryFilePathList(const std::string& paths) { osgDB::Registry::instance()->setLibraryFilePathList(paths); }
129 
131 
132 extern OSGDB_EXPORT std::string findLibraryFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
133 
135 extern OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath);
136 
139 
142 
143 } // namespace osgDB
144 
145 #endif
FilePathList & getDataFilePathList()
Definition: FileUtils.h:114
void setDataFilePathList(const FilePathList &filepath)
Definition: Registry.h:394
OSGDB_EXPORT std::string findFileInDirectory(const std::string &fileName, const std::string &dirName, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
OSGDB_EXPORT std::string findFileInPath(const std::string &filename, const FilePathList &filePath, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
FileType
Definition: FileUtils.h:46
void setDataFilePathList(const FilePathList &filepath)
Definition: FileUtils.h:110
OSGDB_EXPORT std::string findDataFile(const std::string &filename, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
OSGDB_EXPORT bool setCurrentWorkingDirectory(const std::string &newCurrentWorkingDirectory)
OSGDB_EXPORT bool containsCurrentWorkingDirectoryReference(const FilePathList &paths)
OSGDB_EXPORT std::string getCurrentWorkingDirectory(void)
OSGDB_EXPORT std::string findLibraryFile(const std::string &filename, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
FilePathList & getDataFilePathList()
Definition: Registry.h:400
OSGDB_EXPORT void appendPlatformSpecificResourceFilePaths(FilePathList &filepath)
OSGDB_EXPORT DirectoryContents getSortedDirectoryContents(const std::string &dirName)
OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string &filename)
OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string &paths, FilePathList &filepath)
Definition: Archive.h:24
void setLibraryFilePathList(const FilePathList &filepaths)
Definition: FileUtils.h:126
OSGDB_EXPORT bool fileExists(const std::string &filename)
OSGDB_EXPORT bool makeDirectory(const std::string &directoryPath)
OSGDB_EXPORT FileOpResult::Value copyFile(const std::string &source, const std::string &destination)
std::deque< std::string > FilePathList
Definition: Callbacks.h:28
#define OSGDB_EXPORT
Definition: Export.h:39
OSGDB_EXPORT bool makeDirectoryForFile(const std::string &filePath)
CaseSensitivity
Definition: Callbacks.h:30
OSGDB_EXPORT FILE * fopen(const char *filename, const char *mode)
static Registry * instance(bool erase=false)
FilePathList & getLibraryFilePathList()
Definition: FileUtils.h:130
FilePathList & getLibraryFilePathList()
Definition: Registry.h:416
void setLibraryFilePathList(const FilePathList &filepath)
Definition: Registry.h:410
std::vector< std::string > DirectoryContents
Definition: FileUtils.h:67
OSGDB_EXPORT void appendPlatformSpecificLibraryFilePaths(FilePathList &filepath)
OSGDB_EXPORT FileType fileType(const std::string &filename)
OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string &dirName)