From f15437c7136ade8581f8a6bba952a76a1aa7c591 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Tue, 11 Apr 2017 15:21:43 -0400 Subject: [PATCH] tweak movefile behavior --- src/fs_movefile.cpp | 24 +++++++++++++----------- src/fs_movefile.hpp | 14 ++++++++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/fs_movefile.cpp b/src/fs_movefile.cpp index 1ca1fa54..6ec330ca 100644 --- a/src/fs_movefile.cpp +++ b/src/fs_movefile.cpp @@ -36,6 +36,15 @@ using std::vector; namespace fs { + int + movefile(const vector &basepaths, + const string &fusepath, + const size_t additional_size, + int &origfd) + { + return fs::movefile(basepaths,fusepath.c_str(),additional_size,origfd); + } + int movefile(const vector &basepaths, const char *fusepath, @@ -95,19 +104,12 @@ namespace fs return -1; } - rv = fs::unlink(fdin_path); - if(rv == -1) - { - fs::close(fdin); - fs::close(fdout); - fs::unlink(fdout_path); - return -1; - } + // should we care if it fails? + fs::unlink(fdin_path); + std::swap(origfd,fdout); fs::close(fdin); - fs::close(origfd); - - origfd = fdout; + fs::close(fdout); return 0; } diff --git a/src/fs_movefile.hpp b/src/fs_movefile.hpp index b34b0135..381e92db 100644 --- a/src/fs_movefile.hpp +++ b/src/fs_movefile.hpp @@ -23,10 +23,16 @@ namespace fs { int - movefile(const vector &basepaths, - const char *fusepath, - const size_t additional_size, - int &origfd); + movefile(const std::vector &basepaths, + const std::string &fusepath, + const size_t additional_size, + int &origfd); + + int + movefile(const std::vector &basepaths, + const char *fusepath, + const size_t additional_size, + int &origfd); } #endif