To avoid noise in documentation replaced nested namespaced enum with enum with FILE_COPY_ wording prefixed into enum values.

This commit is contained in:
Robert Osfield 2016-11-15 08:57:24 +00:00
parent 80f75bcbdd
commit 87a3648e68
2 changed files with 21 additions and 24 deletions

View File

@ -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);

View File

@ -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;
}