Add MoveFileTo

This commit is contained in:
Jacob Dufault 2017-07-28 17:08:18 -07:00
parent ea5508a699
commit a9bac06b83
3 changed files with 11 additions and 0 deletions

View File

@ -39,6 +39,7 @@ void SetCurrentThreadName(const std::string& thread_name);
int64_t GetLastModificationTime(const std::string& absolute_path);
void MoveFileTo(const std::string& destination, const std::string& source);
void CopyFileTo(const std::string& destination, const std::string& source);
bool IsSymLink(const std::string& path);

View File

@ -186,6 +186,11 @@ int64_t GetLastModificationTime(const std::string& absolute_path) {
return buf.st_mtime;
}
void MoveFileTo(const std::string& dest, const std::string& source) {
// TODO/FIXME - do a real move.
CopyFileTo(dest, source);
}
// See http://stackoverflow.com/q/13198627
void CopyFileTo(const std::string& dest, const std::string& source) {
int fd_from = open(source.c_str(), O_RDONLY);

View File

@ -204,6 +204,11 @@ int64_t GetLastModificationTime(const std::string& absolute_path) {
return buf.st_mtime;
}
void MoveFileTo(const std::string& destination, const std::string& source) {
MoveFile(source.c_str(),
destination.c_str());
}
void CopyFileTo(const std::string& destination, const std::string& source) {
CopyFile(
source.c_str(),