git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@90 d34b734f-a00e-4b39-a726-e4eeb87269abadeniz_1
@@ -31,6 +31,7 @@ | |||
#include <unistd.h> | |||
#include <sys/types.h> | |||
#include <cstdio> | |||
#include <cstdlib> | |||
#include <cstring> | |||
#include <cerrno> | |||
@@ -45,6 +46,21 @@ | |||
namespace CodeDweller { | |||
void FileOps::moveFile(std::string const &from, std::string const &to) { | |||
#ifdef _WIN32 | |||
if (MoveFile(from.c_str(), to.c_str()) == 0) { | |||
#else | |||
if (rename(from.c_str(), to.c_str()) != 0) { | |||
#endif | |||
throw std::runtime_error("Error moving file \"" + from + | |||
"\" to file \"" + to + "\": " + | |||
FileReference::getErrorText()); | |||
} | |||
} | |||
#ifdef _WIN32 | |||
char const FilePath::DirectorySeparator = '\\'; | |||
#else |
@@ -35,6 +35,24 @@ | |||
namespace CodeDweller { | |||
/** Abstracts OS specifics for manipulating files. */ | |||
class FileOps { | |||
public: | |||
/** Move a file. | |||
@param[in] from is the path of the file to move. | |||
@param[in] to is the path the move the file to. | |||
@throws std::runtime_error if an error occurs. | |||
*/ | |||
static void moveFile(std::string const &from, std::string const &to); | |||
}; | |||
/** Abstracts OS specifics for manipulating file paths. */ | |||
class FilePath { | |||