tweak movefile behavior

This commit is contained in:
Antonio SJ Musumeci 2017-04-11 15:21:43 -04:00
parent d9be1c4841
commit f15437c713
2 changed files with 23 additions and 15 deletions

View File

@ -36,6 +36,15 @@ using std::vector;
namespace fs namespace fs
{ {
int
movefile(const vector<string> &basepaths,
const string &fusepath,
const size_t additional_size,
int &origfd)
{
return fs::movefile(basepaths,fusepath.c_str(),additional_size,origfd);
}
int int
movefile(const vector<string> &basepaths, movefile(const vector<string> &basepaths,
const char *fusepath, const char *fusepath,
@ -95,19 +104,12 @@ namespace fs
return -1; return -1;
} }
rv = fs::unlink(fdin_path); // should we care if it fails?
if(rv == -1) fs::unlink(fdin_path);
{
fs::close(fdin);
fs::close(fdout);
fs::unlink(fdout_path);
return -1;
}
std::swap(origfd,fdout);
fs::close(fdin); fs::close(fdin);
fs::close(origfd); fs::close(fdout);
origfd = fdout;
return 0; return 0;
} }

View File

@ -23,10 +23,16 @@
namespace fs namespace fs
{ {
int int
movefile(const vector<string> &basepaths, movefile(const std::vector<std::string> &basepaths,
const char *fusepath, const std::string &fusepath,
const size_t additional_size, const size_t additional_size,
int &origfd); int &origfd);
int
movefile(const std::vector<std::string> &basepaths,
const char *fusepath,
const size_t additional_size,
int &origfd);
} }
#endif #endif