Merge branch 'master' into develop
This commit is contained in:
commit
498623ddab
@ -14,11 +14,24 @@ class Dir: public virtual Node {
|
|||||||
public:
|
public:
|
||||||
virtual ~Dir() {}
|
virtual ~Dir() {}
|
||||||
|
|
||||||
|
enum class EntryType {
|
||||||
|
DIR = 0,
|
||||||
|
FILE = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Entry {
|
||||||
|
Entry(EntryType type_, const std::string &name_): type(type_), name(name_) {}
|
||||||
|
EntryType type;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
virtual std::unique_ptr<File> createFile(const std::string &name, mode_t mode) = 0;
|
virtual std::unique_ptr<File> createFile(const std::string &name, mode_t mode) = 0;
|
||||||
virtual std::unique_ptr<Dir> createDir(const std::string &name, mode_t mode) = 0;
|
virtual std::unique_ptr<Dir> createDir(const std::string &name, mode_t mode) = 0;
|
||||||
virtual void rmdir() = 0;
|
virtual void rmdir() = 0;
|
||||||
|
|
||||||
virtual std::unique_ptr<std::vector<std::string>> children() const = 0;
|
//TODO Allow alternative implementation returning only children names without more information
|
||||||
|
//virtual std::unique_ptr<std::vector<std::string>> children() const = 0;
|
||||||
|
virtual std::unique_ptr<std::vector<Entry>> children() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace fspp */
|
} /* namespace fspp */
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
#include "../fs_interface/Dir.h"
|
||||||
|
|
||||||
namespace fspp {
|
namespace fspp {
|
||||||
namespace fuse {
|
namespace fuse {
|
||||||
@ -32,7 +33,8 @@ public:
|
|||||||
virtual void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) = 0;
|
virtual void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) = 0;
|
||||||
virtual void utimens(const boost::filesystem::path &path, const timespec times[2]) = 0;
|
virtual void utimens(const boost::filesystem::path &path, const timespec times[2]) = 0;
|
||||||
virtual void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) = 0;
|
virtual void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) = 0;
|
||||||
virtual std::unique_ptr<std::vector<std::string>> readDir(const boost::filesystem::path &path) = 0;
|
//TODO We shouldn't use Dir::Entry here, that's in another layer
|
||||||
|
virtual std::unique_ptr<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ int Fuse::readdir(const bf::path &path, void *buf, fuse_fill_dir_t filler, off_t
|
|||||||
//We could pass file metadata to filler() in its third parameter,
|
//We could pass file metadata to filler() in its third parameter,
|
||||||
//but it doesn't help performance since fuse seems to ignore it.
|
//but it doesn't help performance since fuse seems to ignore it.
|
||||||
//It does getattr() calls on all entries nevertheless.
|
//It does getattr() calls on all entries nevertheless.
|
||||||
if (filler(buf, entry.c_str(), nullptr, 0) != 0) {
|
if (filler(buf, entry.name.c_str(), nullptr, 0) != 0) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ void FilesystemImpl::rename(const bf::path &from, const bf::path &to) {
|
|||||||
node->rename(to);
|
node->rename(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<vector<string>> FilesystemImpl::readDir(const bf::path &path) {
|
unique_ptr<vector<Dir::Entry>> FilesystemImpl::readDir(const bf::path &path) {
|
||||||
auto dir = LoadDir(path);
|
auto dir = LoadDir(path);
|
||||||
return dir->children();
|
return dir->children();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ namespace fspp {
|
|||||||
class Node;
|
class Node;
|
||||||
class File;
|
class File;
|
||||||
class OpenFile;
|
class OpenFile;
|
||||||
class Dir;
|
|
||||||
|
|
||||||
class FilesystemImpl: public fuse::Filesystem {
|
class FilesystemImpl: public fuse::Filesystem {
|
||||||
public:
|
public:
|
||||||
@ -35,7 +34,7 @@ public:
|
|||||||
void rmdir(const boost::filesystem::path &path) override;
|
void rmdir(const boost::filesystem::path &path) override;
|
||||||
void unlink(const boost::filesystem::path &path) override;
|
void unlink(const boost::filesystem::path &path) override;
|
||||||
void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override;
|
void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override;
|
||||||
std::unique_ptr<std::vector<std::string>> readDir(const boost::filesystem::path &path) override;
|
std::unique_ptr<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) override;
|
||||||
void utimens(const boost::filesystem::path &path, const timespec times[2]) override;
|
void utimens(const boost::filesystem::path &path, const timespec times[2]) override;
|
||||||
void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) override;
|
void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) override;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using std::vector;
|
|||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
using namespace fspp::fuse;
|
using namespace fspp::fuse;
|
||||||
|
using fspp::Dir;
|
||||||
|
|
||||||
unique_ptr<vector<string>> LARGE_DIR(int num_entries) {
|
unique_ptr<vector<string>> LARGE_DIR(int num_entries) {
|
||||||
auto result = make_unique<vector<string>>();
|
auto result = make_unique<vector<string>>();
|
||||||
|
@ -79,7 +79,10 @@ void FuseReadDirTest::closeDir(DIR *dir) {
|
|||||||
EXPECT_EQ(0, retval) << "Closing dir failed";
|
EXPECT_EQ(0, retval) << "Closing dir failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
Action<vector<string>*(const char*)> FuseReadDirTest::ReturnDirEntries(vector<string> entries) {
|
Action<vector<fspp::Dir::Entry>*(const char*)> FuseReadDirTest::ReturnDirEntries(vector<std::string> entries) {
|
||||||
vector<string> *direntries = new vector<string>(entries);
|
vector<fspp::Dir::Entry> *direntries = new vector<fspp::Dir::Entry>(entries.size(), fspp::Dir::Entry(fspp::Dir::EntryType::FILE, ""));
|
||||||
|
for(unsigned int i = 0; i < entries.size(); ++i) {
|
||||||
|
(*direntries)[i].name = entries[i];
|
||||||
|
}
|
||||||
return Return(direntries);
|
return Return(direntries);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "../../../testutils/FuseTest.h"
|
#include "../../../testutils/FuseTest.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include "../../../../fs_interface/Dir.h"
|
||||||
|
|
||||||
class FuseReadDirTest: public FuseTest {
|
class FuseReadDirTest: public FuseTest {
|
||||||
public:
|
public:
|
||||||
@ -12,7 +13,7 @@ public:
|
|||||||
std::unique_ptr<std::vector<std::string>> ReadDir(const char *dirname);
|
std::unique_ptr<std::vector<std::string>> ReadDir(const char *dirname);
|
||||||
int ReadDirReturnError(const char *dirname);
|
int ReadDirReturnError(const char *dirname);
|
||||||
|
|
||||||
static ::testing::Action<std::vector<std::string>*(const char*)> ReturnDirEntries(std::vector<std::string> entries);
|
static ::testing::Action<std::vector<fspp::Dir::Entry>*(const char*)> ReturnDirEntries(std::vector<std::string> entries);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DIR *openDir(TempTestFS *fs, const char *dirname);
|
DIR *openDir(TempTestFS *fs, const char *dirname);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "../../fuse/Filesystem.h"
|
#include "../../fuse/Filesystem.h"
|
||||||
#include "../../fuse/FuseErrnoException.h"
|
#include "../../fuse/FuseErrnoException.h"
|
||||||
#include "../../fuse/Fuse.h"
|
#include "../../fuse/Fuse.h"
|
||||||
|
#include "../../fs_interface/Dir.h"
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
@ -57,10 +58,10 @@ public:
|
|||||||
return rename(from.c_str(), to.c_str());
|
return rename(from.c_str(), to.c_str());
|
||||||
}
|
}
|
||||||
MOCK_METHOD2(rename, void(const char*, const char*));
|
MOCK_METHOD2(rename, void(const char*, const char*));
|
||||||
std::unique_ptr<std::vector<std::string>> readDir(const boost::filesystem::path &path) {
|
std::unique_ptr<std::vector<fspp::Dir::Entry>> readDir(const boost::filesystem::path &path) {
|
||||||
return std::unique_ptr<std::vector<std::string>>(readDir(path.c_str()));
|
return std::unique_ptr<std::vector<fspp::Dir::Entry>>(readDir(path.c_str()));
|
||||||
}
|
}
|
||||||
MOCK_METHOD1(readDir, std::vector<std::string>*(const char*));
|
MOCK_METHOD1(readDir, std::vector<fspp::Dir::Entry>*(const char*));
|
||||||
void utimens(const boost::filesystem::path &path, const timespec ts[2]) override {
|
void utimens(const boost::filesystem::path &path, const timespec ts[2]) override {
|
||||||
return utimens(path.c_str(), ts);
|
return utimens(path.c_str(), ts);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user