From 87a3648e681b795ada5359fb3c49fece79416560 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 15 Nov 2016 08:57:24 +0000 Subject: [PATCH] To avoid noise in documentation replaced nested namespaced enum with enum with FILE_COPY_ wording prefixed into enum values. --- include/osgDB/FileUtils | 27 ++++++++++++--------------- src/osgDB/FileUtils.cpp | 18 +++++++++--------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/include/osgDB/FileUtils b/include/osgDB/FileUtils index 797fdf391..94b55fe07 100644 --- a/include/osgDB/FileUtils +++ b/include/osgDB/FileUtils @@ -84,26 +84,23 @@ extern OSGDB_EXPORT DirectoryContents getSortedDirectoryContents(const std::stri * still work unchanged. */ extern OSGDB_EXPORT DirectoryContents expandWildcardsInFilename(const std::string& filename); -namespace FileOpResult { - enum Value - { - OK, /**< Operation done. */ - SOURCE_EQUALS_DESTINATION, /**< Operation is useless (source == destination). */ - BAD_ARGUMENT, - SOURCE_MISSING, /**< Source file doesn't exist. */ - SOURCE_NOT_OPENED, /**< Error opening source file. */ - DESTINATION_NOT_OPENED, /**< Error opening destination file. */ - READ_ERROR, - WRITE_ERROR - }; -} +enum CopyFileResult +{ + COPY_FILE_OK, /**< Operation done. */ + COPY_FILE_SOURCE_EQUALS_DESTINATION, /**< Operation is useless (source == destination). */ + COPY_FILE_BAD_ARGUMENT, + COPY_FILE_SOURCE_MISSING, /**< Source file doesn't exist. */ + COPY_FILE_SOURCE_NOT_OPENED, /**< Error opening source file. */ + COPY_FILE_DESTINATION_NOT_OPENED, /**< Error opening destination file. */ + COPY_FILE_READ_ERROR, + COPY_FILE_WRITE_ERROR +}; /** Copy a file to another location, overwriting if necessary. * You must provide full path for both source and destination. * \return true on success, or if source and destination are the same. - * \todo Replace the implementation with filesystem functions from TR2 when available. */ -extern OSGDB_EXPORT FileOpResult::Value copyFile(const std::string & source, const std::string & destination); +extern OSGDB_EXPORT CopyFileResult copyFile(const std::string & source, const std::string & destination); diff --git a/src/osgDB/FileUtils.cpp b/src/osgDB/FileUtils.cpp index 7d86b3788..33c00b37c 100644 --- a/src/osgDB/FileUtils.cpp +++ b/src/osgDB/FileUtils.cpp @@ -601,26 +601,26 @@ osgDB::DirectoryContents osgDB::expandWildcardsInFilename(const std::string& fil return contents; } -osgDB::FileOpResult::Value osgDB::copyFile(const std::string & source, const std::string & destination) +osgDB::CopyFileResult osgDB::copyFile(const std::string & source, const std::string & destination) { if (source.empty() || destination.empty()) { OSG_INFO << "copyFile(): Empty file name." << std::endl; - return FileOpResult::BAD_ARGUMENT; + return COPY_FILE_BAD_ARGUMENT; } // Check if source and destination are the same if (source == destination || osgDB::getRealPath(source) == osgDB::getRealPath(destination)) { OSG_INFO << "copyFile(): Source and destination point to the same file: source=" << source << ", destination=" << destination << std::endl; - return FileOpResult::SOURCE_EQUALS_DESTINATION; + return COPY_FILE_SOURCE_EQUALS_DESTINATION; } // Check if source file exists if (!osgDB::fileExists(source)) { OSG_INFO << "copyFile(): Source file does not exist: " << source << std::endl; - return FileOpResult::SOURCE_MISSING; + return COPY_FILE_SOURCE_MISSING; } // Open source file @@ -628,7 +628,7 @@ osgDB::FileOpResult::Value osgDB::copyFile(const std::string & source, const std if (!fin) { OSG_NOTICE << "copyFile(): Can't read source file: " << source << std::endl; - return FileOpResult::SOURCE_NOT_OPENED; // Return success since it's not an output error. + return COPY_FILE_SOURCE_NOT_OPENED; // Return success since it's not an output error. } // Ensure the directory exists or else the FBX SDK will fail @@ -642,7 +642,7 @@ osgDB::FileOpResult::Value osgDB::copyFile(const std::string & source, const std if (!fout) { OSG_NOTICE << "copyFile(): Can't write destination file: " << destination << std::endl; - return FileOpResult::DESTINATION_NOT_OPENED; + return COPY_FILE_DESTINATION_NOT_OPENED; } // Copy file @@ -657,16 +657,16 @@ osgDB::FileOpResult::Value osgDB::copyFile(const std::string & source, const std if (!fout.good()) { OSG_NOTICE << "copyFile(): Error writing destination file: " << destination << std::endl; - return FileOpResult::WRITE_ERROR; + return COPY_FILE_WRITE_ERROR; } if (!fin.eof()) { OSG_NOTICE << "copyFile(): Error reading source file: " << source << std::endl; - return FileOpResult::READ_ERROR; + return COPY_FILE_READ_ERROR; } - return FileOpResult::OK; + return COPY_FILE_OK; }