Generalize remove for dirs and files

This commit is contained in:
Sebastian Messmer 2015-04-10 23:24:28 +02:00
parent 64fcd2094a
commit f746d83141
4 changed files with 4 additions and 4 deletions

View File

@ -27,7 +27,6 @@ public:
virtual std::unique_ptr<OpenFile> createAndOpenFile(const std::string &name, mode_t mode) = 0; virtual std::unique_ptr<OpenFile> createAndOpenFile(const std::string &name, mode_t mode) = 0;
virtual void createDir(const std::string &name, mode_t mode) = 0; virtual void createDir(const std::string &name, mode_t mode) = 0;
virtual void rmdir() = 0;
//TODO Allow alternative implementation returning only children names without more information //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<std::string>> children() const = 0;

View File

@ -15,7 +15,6 @@ public:
virtual std::unique_ptr<OpenFile> open(int flags) const = 0; virtual std::unique_ptr<OpenFile> open(int flags) const = 0;
virtual void truncate(off_t size) const = 0; virtual void truncate(off_t size) const = 0;
virtual void unlink() = 0;
}; };
} }

View File

@ -16,6 +16,7 @@ public:
virtual void access(int mask) const = 0; virtual void access(int mask) const = 0;
virtual void rename(const boost::filesystem::path &to) = 0; virtual void rename(const boost::filesystem::path &to) = 0;
virtual void utimens(const timespec times[2]) = 0; virtual void utimens(const timespec times[2]) = 0;
virtual void remove() = 0;
}; };
} }

View File

@ -84,6 +84,7 @@ int FilesystemImpl::read(int descriptor, void *buf, size_t count, off_t offset)
} }
void FilesystemImpl::write(int descriptor, const void *buf, size_t count, off_t offset) { void FilesystemImpl::write(int descriptor, const void *buf, size_t count, off_t offset) {
//printf("Write %d bytes to offset %d\n", count, offset);fflush(stdout);
_open_files.get(descriptor)->write(buf, count, offset); _open_files.get(descriptor)->write(buf, count, offset);
} }
@ -114,12 +115,12 @@ void FilesystemImpl::mkdir(const bf::path &path, mode_t mode) {
void FilesystemImpl::rmdir(const bf::path &path) { void FilesystemImpl::rmdir(const bf::path &path) {
auto dir = LoadDir(path); auto dir = LoadDir(path);
dir->rmdir(); dir->remove();
} }
void FilesystemImpl::unlink(const bf::path &path) { void FilesystemImpl::unlink(const bf::path &path) {
auto file = LoadFile(path); auto file = LoadFile(path);
file->unlink(); file->remove();
} }
void FilesystemImpl::rename(const bf::path &from, const bf::path &to) { void FilesystemImpl::rename(const bf::path &from, const bf::path &to) {