浏览代码

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 年前
父节点
当前提交
97d91cbab4
共有 2 个文件被更改,包括 34 次插入0 次删除
  1. 16
    0
      filesystem.cpp
  2. 18
    0
      filesystem.hpp

+ 16
- 0
filesystem.cpp 查看文件

@@ -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 查看文件

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


正在加载...
取消
保存