Show
Ignore:
Timestamp:
01/28/10 11:45:40 (4 years ago)
Author:
robert
Message:

Fom Sukender, "Added copyFile() and comments in FileUtils?."

From Robert Osfield, build fix for linux/gcc and reformating to keep coding style consistent with rest of OSG

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgDB/FileUtils

    r10818 r11023  
    2424namespace osgDB { 
    2525 
     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. */ 
     28extern OSGDB_EXPORT FILE* fopen(const char* filename, const char* mode); 
     29 
     30/** Make a new directory.  Returns true if directory exists or was created. */ 
     31extern OSGDB_EXPORT bool makeDirectory( const std::string &directoryPath ); 
     32 
     33/** Make a new directory for a given file. */ 
     34extern OSGDB_EXPORT bool makeDirectoryForFile( const std::string &filePath ); 
     35     
     36/** Get current working directory. */ 
     37extern OSGDB_EXPORT std::string getCurrentWorkingDirectory( void ); 
     38 
     39/** Set current working directory. */ 
     40extern OSGDB_EXPORT bool setCurrentWorkingDirectory( const std::string &newCurrentWorkingDirectory ); 
     41 
     42 
     43/** return true if a file exists. */ 
     44extern OSGDB_EXPORT bool fileExists(const std::string& filename); 
     45 
    2646enum FileType 
    2747{ 
     
    3050    DIRECTORY 
    3151}; 
    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); 
    5252 
    5353/** return type of file. */ 
     
    7070  * returns an empty array on any error.*/ 
    7171extern OSGDB_EXPORT DirectoryContents getDirectoryContents(const std::string& dirName); 
     72 
     73 
     74 
     75namespace 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*/ 
     94extern OSGDB_EXPORT FileOpResult::Value copyFile(const std::string & source, const std::string & destination); 
    7295 
    7396 
     
    103126extern OSGDB_EXPORT void appendPlatformSpecificResourceFilePaths(FilePathList& filepath); 
    104127 
    105 } 
     128}        // namespace osgDB 
    106129 
    107130#endif