Bladeren bron

Implemented FileOps::moveFile.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@90 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 9 jaren geleden
bovenliggende
commit
97d91cbab4
2 gewijzigde bestanden met toevoegingen van 34 en 0 verwijderingen
  1. 16
    0
      filesystem.cpp
  2. 18
    0
      filesystem.hpp

+ 16
- 0
filesystem.cpp Bestand weergeven

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

+ 18
- 0
filesystem.hpp Bestand weergeven

@@ -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 {


Laden…
Annuleren
Opslaan