OpenSceneGraph 3.6.5
FileUtils
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
24namespace osgDB {
25
28extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode);
29
31extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath );
32
34extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath );
35
37extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void );
38
40extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory );
41
42
44extern OSGDB_EXPORT bool fileExists(const std::string& filename);
45
52
54extern OSGDB_EXPORT FileType fileType(const std::string& filename);
55
57extern OSGDB_EXPORT std::string findFileInPath(const std::string& filename, const FilePathList& filePath,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
58
64extern OSGDB_EXPORT std::string findFileInDirectory(const std::string& fileName,const std::string& dirName,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
65
67typedef std::vector<std::string> DirectoryContents;
68
72extern OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string& dirName);
73
78
85extern OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string& filename);
86
98
103extern OSGDB_EXPORT CopyFileResult copyFile(const std::string & source, const std::string & destination);
104
105
106
108
109inline void setDataFilePathList(const std::string& paths) { osgDB::Registry::instance()->setDataFilePathList(paths); }
110
112
116extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
117
121extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,const Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
122
124
125inline void setLibraryFilePathList(const std::string& paths) { osgDB::Registry::instance()->setLibraryFilePathList(paths); }
126
128
129extern OSGDB_EXPORT std::string findLibraryFile(const std::string& filename,CaseSensitivity caseSensitivity=CASE_SENSITIVE);
130
132extern OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath);
133
136
139
140} // namespace osgDB
141
142#endif
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
OSGDB_EXPORT DirectoryContents getSortedDirectoryContents(const std::string &dirName)
Return the contents of a directory, sorting the names into alphabetic and numberical order.
OSGDB_EXPORT CopyFileResult copyFile(const std::string &source, const std::string &destination)
Copy a file to another location, overwriting if necessary.
CopyFileResult
Definition FileUtils:88
@ COPY_FILE_SOURCE_NOT_OPENED
Error opening source file.
Definition FileUtils:93
@ COPY_FILE_OK
Operation done.
Definition FileUtils:89
@ COPY_FILE_SOURCE_MISSING
Source file doesn't exist.
Definition FileUtils:92
@ COPY_FILE_WRITE_ERROR
Definition FileUtils:96
@ COPY_FILE_DESTINATION_NOT_OPENED
Error opening destination file.
Definition FileUtils:94
@ COPY_FILE_READ_ERROR
Definition FileUtils:95
@ COPY_FILE_SOURCE_EQUALS_DESTINATION
Operation is useless (source == destination).
Definition FileUtils:90
@ COPY_FILE_BAD_ARGUMENT
Definition FileUtils:91
OSGDB_EXPORT std::string findLibraryFile(const std::string &filename, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
OSGDB_EXPORT std::string findFileInPath(const std::string &filename, const FilePathList &filePath, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
find specified file in specified file path.
std::vector< std::string > DirectoryContents
simple list of names to represent a directory's contents.
Definition FileUtils:67
OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string &filename)
Return the list of filenames that match the given filename with wildcards.
OSGDB_EXPORT void convertStringPathIntoFilePathList(const std::string &paths, FilePathList &filepath)
convert a string containing a list of paths delimited either with ';' (Windows) or ':' (All other pla...
OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string &dirName)
Return the contents of a directory.
std::deque< std::string > FilePathList
list of directories to search through which searching for files.
Definition Callbacks:28
OSGDB_EXPORT void appendPlatformSpecificResourceFilePaths(FilePathList &filepath)
void setDataFilePathList(const FilePathList &filepath)
Definition FileUtils:107
OSGDB_EXPORT std::string findFileInDirectory(const std::string &fileName, const std::string &dirName, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
return the directory/filename of a file if its is contained within specified directory.
FileType
Definition FileUtils:47
@ FILE_NOT_FOUND
Definition FileUtils:48
@ REGULAR_FILE
Definition FileUtils:49
@ DIRECTORY
Definition FileUtils:50
OSGDB_EXPORT FILE * fopen(const char *filename, const char *mode)
Overload of the standard fopen function.
OSGDB_EXPORT bool fileExists(const std::string &filename)
return true if a file exists.
OSGDB_EXPORT bool makeDirectoryForFile(const std::string &filePath)
Make a new directory for a given file.
void setLibraryFilePathList(const FilePathList &filepaths)
Definition FileUtils:123
OSGDB_EXPORT bool makeDirectory(const std::string &directoryPath)
Make a new directory.
OSGDB_EXPORT std::string findDataFile(const std::string &filename, CaseSensitivity caseSensitivity=CASE_SENSITIVE)
Search for specified file in file system, checking the DataFilePathList for possible paths,...
FilePathList & getLibraryFilePathList()
Definition FileUtils:127
CaseSensitivity
Definition Callbacks:31
@ CASE_SENSITIVE
Definition Callbacks:32
OSGDB_EXPORT FileType fileType(const std::string &filename)
return type of file.
OSGDB_EXPORT void appendPlatformSpecificLibraryFilePaths(FilePathList &filepath)
OSGDB_EXPORT bool setCurrentWorkingDirectory(const std::string &newCurrentWorkingDirectory)
Set current working directory.
FilePathList & getDataFilePathList()
Definition FileUtils:111
OSGDB_EXPORT bool containsCurrentWorkingDirectoryReference(const FilePathList &paths)
Return true if FilePathList contains a filepath that is significies checking of the current working d...
OSGDB_EXPORT std::string getCurrentWorkingDirectory(void)
Get current working directory.
Options base class used for passing options into plugins to control their operation.
Definition Options:30
FilePathList & getLibraryFilePathList()
get the library file path which is used when search for library (dso/dll's) files.
Definition Registry:423
void setDataFilePathList(const FilePathList &filepath)
Set the data file path using a list of paths stored in a FilePath, which is used when search for data...
Definition Registry:401
FilePathList & getDataFilePathList()
get the data file path which is used when search for data files.
Definition Registry:407
static Registry * instance(bool erase=false)
void setLibraryFilePathList(const FilePathList &filepath)
Set the library file path using a list of paths stored in a FilePath, which is used when search for d...
Definition Registry:417
#define OSGDB_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.