Browse Source

limit need to explicitly call .c_str()

pull/361/head
Antonio SJ Musumeci 8 years ago
parent
commit
e93c946198
  1. 32
      src/fs_base_remove.hpp
  2. 42
      src/fs_base_symlink.hpp
  3. 11
      src/fs_clonepath.cpp
  4. 3
      src/fs_clonepath.hpp
  5. 4
      src/fs_movefile.cpp
  6. 2
      src/link.cpp
  7. 8
      src/rename.cpp
  8. 4
      src/symlink.cpp

32
src/fs_base_remove.hpp

@ -0,0 +1,32 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <string>
#include <stdio.h>
namespace fs
{
static
inline
int
remove(const std::string &pathname)
{
return ::remove(pathname.c_str());
}
}

42
src/fs_base_symlink.hpp

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <string>
#include <unistd.h>
namespace fs
{
static
inline
int
symlink(const std::string &oldpath,
const std::string &newpath)
{
return ::symlink(oldpath.c_str(),newpath.c_str());
}
static
inline
int
symlink(const char *oldpath,
const std::string &newpath)
{
return ::symlink(oldpath,newpath.c_str());
}
}

11
src/fs_clonepath.cpp

@ -23,6 +23,7 @@
#include "fs_base_mkdir.hpp" #include "fs_base_mkdir.hpp"
#include "fs_base_stat.hpp" #include "fs_base_stat.hpp"
#include "fs_base_utime.hpp" #include "fs_base_utime.hpp"
#include "fs_clonepath.hpp"
#include "fs_path.hpp" #include "fs_path.hpp"
#include "fs_xattr.hpp" #include "fs_xattr.hpp"
@ -62,7 +63,7 @@ namespace fs
fs::path::dirname(dirname); fs::path::dirname(dirname);
if(!dirname.empty()) if(!dirname.empty())
{ {
rv = fs::clonepath(fromsrc,tosrc,dirname.c_str());
rv = fs::clonepath(fromsrc,tosrc,dirname);
if(rv == -1) if(rv == -1)
return -1; return -1;
} }
@ -105,4 +106,12 @@ namespace fs
return 0; return 0;
} }
int
clonepath(const std::string &from,
const std::string &to,
const std::string &relative)
{
return fs::clonepath(from,to,relative.c_str());
}
} }

3
src/fs_clonepath.hpp

@ -21,4 +21,7 @@ namespace fs
int clonepath(const std::string &from, int clonepath(const std::string &from,
const std::string &to, const std::string &to,
const char *relative); const char *relative);
int clonepath(const std::string &from,
const std::string &to,
const std::string &relative);
} }

4
src/fs_movefile.cpp

@ -72,7 +72,7 @@ namespace fs
fusedir = fusepath; fusedir = fusepath;
fs::path::dirname(fusedir); fs::path::dirname(fusedir);
rv = fs::clonepath(fdin_path,fdout_path,fusedir.c_str());
rv = fs::clonepath(fdin_path,fdout_path,fusedir);
if(rv == -1) if(rv == -1)
return -1; return -1;
@ -91,7 +91,7 @@ namespace fs
{ {
fs::close(fdin); fs::close(fdin);
fs::close(fdout); fs::close(fdout);
fs::unlink(fdout_path.c_str());
fs::unlink(fdout_path);
return -1; return -1;
} }

2
src/link.cpp

@ -49,7 +49,7 @@ _link_create_path_core(const string &oldbasepath,
if(oldbasepath != newbasepath) if(oldbasepath != newbasepath)
{ {
const ugid::SetRootGuard ugidGuard; const ugid::SetRootGuard ugidGuard;
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath);
if(rv == -1) if(rv == -1)
return errno; return errno;
} }

8
src/rename.cpp

@ -21,6 +21,7 @@
#include "config.hpp" #include "config.hpp"
#include "errno.hpp" #include "errno.hpp"
#include "fs_base_remove.hpp"
#include "fs_base_rename.hpp" #include "fs_base_rename.hpp"
#include "fs_clonepath.hpp" #include "fs_clonepath.hpp"
#include "fs_path.hpp" #include "fs_path.hpp"
@ -32,7 +33,6 @@
using std::string; using std::string;
using std::vector; using std::vector;
using std::set; using std::set;
using mergerfs::Policy;
using namespace mergerfs; using namespace mergerfs;
static static
@ -54,7 +54,7 @@ void
_remove(const vector<string> &toremove) _remove(const vector<string> &toremove)
{ {
for(size_t i = 0, ei = toremove.size(); i != ei; i++) for(size_t i = 0, ei = toremove.size(); i != ei; i++)
::remove(toremove[i].c_str());
fs::remove(toremove[i]);
} }
static static
@ -70,7 +70,7 @@ _rename(const std::string &oldbasepath,
if(oldbasepath != newbasepath) if(oldbasepath != newbasepath)
{ {
const ugid::SetRootGuard guard; const ugid::SetRootGuard guard;
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath.c_str());
rv = fs::clonepath(newbasepath,oldbasepath,newfusedirpath);
if(rv == -1) if(rv == -1)
return -1; return -1;
} }
@ -173,7 +173,7 @@ _clonepath(Policy::Func::Search searchFunc,
{ {
const ugid::SetRootGuard ugidGuard; const ugid::SetRootGuard ugidGuard;
fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath.c_str());
fs::clonepath(*srcbasepath[0],dstbasepath,fusedirpath);
} }
return POLICY_SUCCESS; return POLICY_SUCCESS;

4
src/symlink.cpp

@ -23,6 +23,7 @@
#include "config.hpp" #include "config.hpp"
#include "errno.hpp" #include "errno.hpp"
#include "fs_base_symlink.hpp"
#include "fs_clonepath.hpp" #include "fs_clonepath.hpp"
#include "fs_path.hpp" #include "fs_path.hpp"
#include "rv.hpp" #include "rv.hpp"
@ -31,7 +32,6 @@
using std::string; using std::string;
using std::vector; using std::vector;
using mergerfs::Policy;
using namespace mergerfs; using namespace mergerfs;
static static
@ -56,7 +56,7 @@ _symlink_loop_core(const string &existingpath,
fs::path::make(&newbasepath,newpath,fullnewpath); fs::path::make(&newbasepath,newpath,fullnewpath);
rv = ::symlink(oldpath,fullnewpath.c_str());
rv = fs::symlink(oldpath,fullnewpath);
return error::calc(rv,error,errno); return error::calc(rv,error,errno);
} }

Loading…
Cancel
Save