diff --git a/src/access.cpp b/src/access.cpp index f1611310..824dbfd9 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -52,7 +52,7 @@ _access(const fs::find::Func searchFunc, const int mask) { int rv; - fs::Paths paths; + Paths paths; rv = searchFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) diff --git a/src/chmod.cpp b/src/chmod.cpp index 7109bdbb..8861533b 100644 --- a/src/chmod.cpp +++ b/src/chmod.cpp @@ -47,14 +47,14 @@ _chmod(const fs::find::Func actionFunc, { int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::chmod(i->full.c_str(),mode); diff --git a/src/chown.cpp b/src/chown.cpp index 4ff52fcb..67847c38 100644 --- a/src/chown.cpp +++ b/src/chown.cpp @@ -49,14 +49,14 @@ _chown(const fs::find::Func actionFunc, { int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::lchown(i->full.c_str(),uid,gid); diff --git a/src/create.cpp b/src/create.cpp index 0eb9c84d..44569dcb 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -56,8 +56,8 @@ _create(const fs::find::Func searchFunc, int rv; string path; string dirname; - fs::Paths createpath; - fs::Paths existingpath; + Paths createpath; + Paths existingpath; dirname = fs::dirname(fusepath); rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); diff --git a/src/fs.hpp b/src/fs.hpp index bc1518f9..92841c1f 100644 --- a/src/fs.hpp +++ b/src/fs.hpp @@ -29,6 +29,8 @@ #include #include +#include "path.hpp" + namespace fs { using std::size_t; @@ -36,30 +38,6 @@ namespace fs using std::vector; using std::map; - struct Path - { - Path() {} - - explicit - Path(const string &b, - const string &f) - : base(b), - full(f) - {} - - explicit - Path(const char *b, - const string &f) - : base(b), - full(f) - {} - - string base; - string full; - }; - - typedef vector Paths; - string dirname(const string &path); string basename(const string &path); diff --git a/src/getattr.cpp b/src/getattr.cpp index 9779894a..3b83cb0e 100644 --- a/src/getattr.cpp +++ b/src/getattr.cpp @@ -72,7 +72,7 @@ _getattr(const fs::find::Func searchFunc, struct stat &buf) { int rv; - fs::Paths path; + Paths path; rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) diff --git a/src/getxattr.cpp b/src/getxattr.cpp index 52b949dd..44f7a1b4 100644 --- a/src/getxattr.cpp +++ b/src/getxattr.cpp @@ -167,7 +167,7 @@ _getxattr_user_mergerfs_allpaths(const vector &srcmounts, static int -_getxattr_user_mergerfs(const fs::Path &path, +_getxattr_user_mergerfs(const Path &path, const vector &srcmounts, const string &fusepath, const char *attrname, @@ -200,7 +200,7 @@ _getxattr(const fs::find::Func searchFunc, { #ifndef WITHOUT_XATTR int rv; - fs::Paths path; + Paths path; rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) diff --git a/src/ioctl.cpp b/src/ioctl.cpp index d3e62fee..dd5223b6 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -93,7 +93,7 @@ _ioctl_dir_base(const fs::find::Func searchFunc, { int fd; int rv; - fs::Paths path; + Paths path; rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) diff --git a/src/link.cpp b/src/link.cpp index 64c991a4..644f7395 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -56,7 +56,7 @@ _single_link(const fs::find::Func searchFunc, if(rv == -1 && errno == ENOENT) { string newpathdir; - fs::Paths foundpath; + Paths foundpath; newpathdir = fs::dirname(newpath); rv = searchFunc(srcmounts,newpathdir,minfreespace,foundpath); @@ -85,14 +85,14 @@ _link(const fs::find::Func searchFunc, { int rv; int error; - fs::Paths oldpaths; + Paths oldpaths; rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = oldpaths.begin(), ei = oldpaths.end(); i != ei; ++i) { rv = _single_link(searchFunc,srcmounts,minfreespace,i->base,oldpath,newpath); diff --git a/src/listxattr.cpp b/src/listxattr.cpp index dcfdb17d..442624b5 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -78,7 +78,7 @@ _listxattr(const fs::find::Func searchFunc, { #ifndef WITHOUT_XATTR int rv; - fs::Paths path; + Paths path; rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) diff --git a/src/mkdir.cpp b/src/mkdir.cpp index 6d063a48..971a1bd8 100644 --- a/src/mkdir.cpp +++ b/src/mkdir.cpp @@ -52,8 +52,8 @@ _mkdir(const fs::find::Func searchFunc, int error; string dirname; string fullpath; - fs::Paths createpaths; - fs::Paths existingpath; + Paths createpaths; + Paths existingpath; dirname = fs::dirname(fusepath); rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); @@ -65,7 +65,7 @@ _mkdir(const fs::find::Func searchFunc, return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = createpaths.begin(), ei = createpaths.end(); i != ei; ++i) { if(i->base != existingpath[0].base) diff --git a/src/mknod.cpp b/src/mknod.cpp index 17d4e171..156f75ce 100644 --- a/src/mknod.cpp +++ b/src/mknod.cpp @@ -55,8 +55,8 @@ _mknod(const fs::find::Func searchFunc, int error; string dirname; string fullpath; - fs::Paths createpaths; - fs::Paths existingpath; + Paths createpaths; + Paths existingpath; dirname = fs::dirname(fusepath); rv = searchFunc(srcmounts,dirname,minfreespace,existingpath); @@ -68,7 +68,7 @@ _mknod(const fs::find::Func searchFunc, return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = createpaths.begin(), ei = createpaths.end(); i != ei; ++i) { if(i->base != existingpath[0].base) diff --git a/src/open.cpp b/src/open.cpp index b918908d..8eb60916 100644 --- a/src/open.cpp +++ b/src/open.cpp @@ -50,7 +50,7 @@ _open(const fs::find::Func searchFunc, { int fd; int rv; - fs::Paths path; + Paths path; rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) diff --git a/src/path.hpp b/src/path.hpp new file mode 100644 index 00000000..9344f5d3 --- /dev/null +++ b/src/path.hpp @@ -0,0 +1,55 @@ +/* + The MIT License (MIT) + + Copyright (c) 2014 Antonio SJ Musumeci + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef __PATH_HPP__ +#define __PATH_HPP__ + +#include +#include + +struct Path +{ + Path() {} + + explicit + Path(const std::string &b, + const std::string &f) + : base(b), + full(f) + {} + + explicit + Path(const char *b, + const std::string &f) + : base(b), + full(f) + {} + + std::string base; + std::string full; +}; + +typedef std::vector Paths; + +#endif /* __PATH_HPP__ */ diff --git a/src/readlink.cpp b/src/readlink.cpp index 223abb9f..9a17bf01 100644 --- a/src/readlink.cpp +++ b/src/readlink.cpp @@ -49,7 +49,7 @@ _readlink(const fs::find::Func searchFunc, const size_t size) { int rv; - fs::Paths path; + Paths path; rv = searchFunc(srcmounts,fusepath,minfreespace,path); if(rv == -1) diff --git a/src/removexattr.cpp b/src/removexattr.cpp index 4c2cc6ef..bbf6576e 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -50,14 +50,14 @@ _removexattr(const fs::find::Func actionFunc, #ifndef WITHOUT_XATTR int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::lremovexattr(i->full.c_str(),attrname); diff --git a/src/rename.cpp b/src/rename.cpp index f1f6e9f8..822c50dc 100644 --- a/src/rename.cpp +++ b/src/rename.cpp @@ -44,7 +44,7 @@ int _single_rename(const fs::find::Func searchFunc, const vector &srcmounts, const size_t minfreespace, - const fs::Path &oldpath, + const Path &oldpath, const string &newpath) { int rv; @@ -54,7 +54,7 @@ _single_rename(const fs::find::Func searchFunc, if(rv == -1 && errno == ENOENT) { string dirname; - fs::Paths newpathdir; + Paths newpathdir; dirname = fs::dirname(newpath); rv = searchFunc(srcmounts,dirname,minfreespace,newpathdir); @@ -83,14 +83,14 @@ _rename(const fs::find::Func searchFunc, { int rv; int error; - fs::Paths oldpaths; + Paths oldpaths; rv = actionFunc(srcmounts,oldpath,minfreespace,oldpaths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = oldpaths.begin(), ei = oldpaths.end(); i != ei; ++i) { rv = _single_rename(searchFunc,srcmounts,minfreespace,*i,newpath); diff --git a/src/rmdir.cpp b/src/rmdir.cpp index 79558872..25befb49 100644 --- a/src/rmdir.cpp +++ b/src/rmdir.cpp @@ -47,14 +47,14 @@ _rmdir(const fs::find::Func actionFunc, { int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::rmdir(i->full.c_str()); diff --git a/src/setxattr.cpp b/src/setxattr.cpp index b144d583..527d385c 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -252,14 +252,14 @@ _setxattr(const fs::find::Func actionFunc, #ifndef WITHOUT_XATTR int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::lsetxattr(i->full.c_str(),attrname,attrval,attrvalsize,flags); diff --git a/src/symlink.cpp b/src/symlink.cpp index b897ee32..4f8c5453 100644 --- a/src/symlink.cpp +++ b/src/symlink.cpp @@ -48,7 +48,7 @@ _symlink(const fs::find::Func createFunc, int rv; int error; string newpathdir; - fs::Paths newpathdirs; + Paths newpathdirs; newpathdir = fs::dirname(newpath); rv = createFunc(srcmounts,newpathdir,minfreespace,newpathdirs); @@ -56,7 +56,7 @@ _symlink(const fs::find::Func createFunc, return -errno; error = 0; - for(fs::Paths::iterator + for(Paths::iterator i = newpathdirs.begin(), ei = newpathdirs.end(); i != ei; ++i) { i->full = fs::make_path(i->base,newpath); diff --git a/src/truncate.cpp b/src/truncate.cpp index ab1ced6e..dabc53a6 100644 --- a/src/truncate.cpp +++ b/src/truncate.cpp @@ -49,14 +49,14 @@ _truncate(const fs::find::Func actionFunc, { int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::truncate(i->full.c_str(),size); diff --git a/src/unlink.cpp b/src/unlink.cpp index 39aec2ce..f54e51c6 100644 --- a/src/unlink.cpp +++ b/src/unlink.cpp @@ -47,14 +47,14 @@ _unlink(const fs::find::Func actionFunc, { int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::unlink(i->full.c_str()); diff --git a/src/utimens.cpp b/src/utimens.cpp index 7d9185c6..74220b69 100644 --- a/src/utimens.cpp +++ b/src/utimens.cpp @@ -49,14 +49,14 @@ _utimens(const fs::find::Func actionFunc, { int rv; int error; - fs::Paths paths; + Paths paths; rv = actionFunc(srcmounts,fusepath,minfreespace,paths); if(rv == -1) return -errno; error = 0; - for(fs::Paths::const_iterator + for(Paths::const_iterator i = paths.begin(), ei = paths.end(); i != ei; ++i) { rv = ::utimensat(0,i->full.c_str(),ts,AT_SYMLINK_NOFOLLOW);