| | 26 | /** Overload of the standard fopen function. If OSG_USE_UTF8_FILENAME is defined, |
| | 27 | * filename will be expanded from UTF8 to UTF16 and _wfopen will be called. */ |
| | 28 | extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode); |
| | 29 | |
| | 30 | /** Make a new directory. Returns true if directory exists or was created. */ |
| | 31 | extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath ); |
| | 32 | |
| | 33 | /** Make a new directory for a given file. */ |
| | 34 | extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath ); |
| | 35 | |
| | 36 | /** Get current working directory. */ |
| | 37 | extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void ); |
| | 38 | |
| | 39 | /** Set current working directory. */ |
| | 40 | extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory ); |
| | 41 | |
| | 42 | |
| | 43 | /** return true if a file exists. */ |
| | 44 | extern OSGDB_EXPORT bool fileExists(const std::string& filename); |
| | 45 | |
| 32 | | |
| 33 | | // Overload of the standard fopen function. If OSG_USE_UTF8_FILENAME is defined, |
| 34 | | // filename will be expanded from UTF8 to UTF16 and _wfopen will be called. |
| 35 | | extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode); |
| 36 | | |
| 37 | | // Make a new directory. Returns true if directory exists or was created. |
| 38 | | extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath ); |
| 39 | | |
| 40 | | // Make a new directory for a given file. |
| 41 | | extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath ); |
| 42 | | |
| 43 | | // Get current working directory. |
| 44 | | extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void ); |
| 45 | | |
| 46 | | // Set current working directory. |
| 47 | | extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory ); |
| 48 | | |
| 49 | | |
| 50 | | /** return true if a file exists. */ |
| 51 | | extern OSGDB_EXPORT bool fileExists(const std::string& filename); |
| | 72 | |
| | 73 | |
| | 74 | |
| | 75 | namespace FileOpResult { |
| | 76 | enum Value |
| | 77 | { |
| | 78 | OK, /**< Operation done. */ |
| | 79 | SOURCE_EQUALS_DESTINATION, /**< Operation is useless (source == destination). */ |
| | 80 | BAD_ARGUMENT, |
| | 81 | SOURCE_MISSING, /**< Source file doesn't exist. */ |
| | 82 | SOURCE_NOT_OPENED, /**< Error opening source file. */ |
| | 83 | DESTINATION_NOT_OPENED, /**< Error opening destination file. */ |
| | 84 | READ_ERROR, |
| | 85 | WRITE_ERROR |
| | 86 | }; |
| | 87 | } |
| | 88 | |
| | 89 | /** Copy a file to another location, overwriting if necessary. |
| | 90 | * You must provide full path for both source and destination. |
| | 91 | * \return true on success, or if source and destination are the same. |
| | 92 | * \todo Replace the implementation with filesystem functions from TR2 when available. |
| | 93 | */ |
| | 94 | extern OSGDB_EXPORT FileOpResult::Value copyFile(const std::string & source, const std::string & destination); |