Browse Source

move Path object to separate file

pull/77/head
Antonio SJ Musumeci 9 years ago
parent
commit
2bd44568a1
  1. 2
      src/access.cpp
  2. 4
      src/chmod.cpp
  3. 4
      src/chown.cpp
  4. 4
      src/create.cpp
  5. 26
      src/fs.hpp
  6. 2
      src/getattr.cpp
  7. 4
      src/getxattr.cpp
  8. 2
      src/ioctl.cpp
  9. 6
      src/link.cpp
  10. 2
      src/listxattr.cpp
  11. 6
      src/mkdir.cpp
  12. 6
      src/mknod.cpp
  13. 2
      src/open.cpp
  14. 55
      src/path.hpp
  15. 2
      src/readlink.cpp
  16. 4
      src/removexattr.cpp
  17. 8
      src/rename.cpp
  18. 4
      src/rmdir.cpp
  19. 4
      src/setxattr.cpp
  20. 4
      src/symlink.cpp
  21. 4
      src/truncate.cpp
  22. 4
      src/unlink.cpp
  23. 4
      src/utimens.cpp

2
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)

4
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);

4
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);

4
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);

26
src/fs.hpp

@ -29,6 +29,8 @@
#include <vector>
#include <map>
#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<Path> Paths;
string dirname(const string &path);
string basename(const string &path);

2
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)

4
src/getxattr.cpp

@ -167,7 +167,7 @@ _getxattr_user_mergerfs_allpaths(const vector<string> &srcmounts,
static
int
_getxattr_user_mergerfs(const fs::Path &path,
_getxattr_user_mergerfs(const Path &path,
const vector<string> &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)

2
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)

6
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);

2
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)

6
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)

6
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)

2
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)

55
src/path.hpp

@ -0,0 +1,55 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
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 <string>
#include <vector>
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<Path> Paths;
#endif /* __PATH_HPP__ */

2
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)

4
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);

8
src/rename.cpp

@ -44,7 +44,7 @@ int
_single_rename(const fs::find::Func searchFunc,
const vector<string> &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);

4
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());

4
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);

4
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);

4
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);

4
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());

4
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);

Loading…
Cancel
Save