13 #ifndef __STOUT_OS_POSIX_RENAME_HPP__ 14 #define __STOUT_OS_POSIX_RENAME_HPP__ 41 const std::string& from,
42 const std::string& to,
45 if (::
rename(from.c_str(), to.c_str()) != 0) {
53 std::vector<std::string> dirs = {to_dir};
54 if (from_dir != to_dir) {
55 dirs.emplace_back(from_dir);
58 foreach (
const std::string& dir, dirs) {
63 "Failed to fsync directory '" + dir +
"': " + fsync.
error());
73 #endif // __STOUT_OS_POSIX_RENAME_HPP__ Definition: nothing.hpp:16
Definition: errorbase.hpp:36
Definition: errorbase.hpp:50
Definition: posix_signalhandler.hpp:23
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
static Try error(const E &e)
Definition: try.hpp:43
std::string dirname() const
Extracts the component up to, but not including, the final '/'.
Definition: path.hpp:308
Try< Nothing > fsync(int fd)
Definition: fsync.hpp:29
Try< Nothing > rename(const std::string &from, const std::string &to, bool sync=false)
Definition: rename.hpp:40
bool isError() const
Definition: try.hpp:78