Parcourir la source

Implemented FileOps::moveFile.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@90 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz il y a 9 ans
Parent
révision
97d91cbab4
2 fichiers modifiés avec 34 ajouts et 0 suppressions
  1. 16
    0
      filesystem.cpp
  2. 18
    0
      filesystem.hpp

+ 16
- 0
filesystem.cpp Voir le fichier

@@ -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 Voir le fichier

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


Chargement…
Annuler
Enregistrer