This commit is contained in:
Sebastian Messmer 2014-11-12 12:34:35 +01:00
parent afd4066ef7
commit 8561d90de0
5 changed files with 18 additions and 5 deletions

View File

@ -100,12 +100,13 @@ int CryFuse::unlink(const path &path) {
}
}
//TODO
int CryFuse::rmdir(const path &path) {
//printf("rmdir(%s)\n", path.c_str());
auto real_path = _device->RootDir() / path;
int retstat = ::rmdir(real_path.c_str());
return errcode_map(retstat);
try {
_device->rmdir(path);
return 0;
} catch(cryfs::CryErrnoException &e) {
return -e.getErrno();
}
}
//TODO

View File

@ -112,6 +112,11 @@ void CryDevice::mkdir(const bf::path &path, mode_t mode) {
dir->createDir(path.filename().native(), mode);
}
void CryDevice::rmdir(const bf::path &path) {
auto dir = LoadDir(path);
dir->rmdir();
}
void CryDevice::unlink(const bf::path &path) {
auto file = LoadFile(path);
file->unlink();

View File

@ -35,6 +35,7 @@ public:
void access(const bf::path &path, int mask);
int createAndOpenFile(const bf::path &path, mode_t mode);
void mkdir(const bf::path &path, mode_t mode);
void rmdir(const bf::path &path);
void unlink(const bf::path &path);
const bf::path &RootDir() const;

View File

@ -39,4 +39,9 @@ unique_ptr<CryDir> CryDir::createDir(const string &name, mode_t mode) {
return make_unique<CryDir>(device(), path() / name);
}
void CryDir::rmdir() {
int retval = ::rmdir(base_path().c_str());
CHECK_RETVAL(retval);
}
} /* namespace cryfs */

View File

@ -18,6 +18,7 @@ public:
std::unique_ptr<CryFile> createFile(const std::string &name, mode_t mode);
std::unique_ptr<CryDir> createDir(const std::string &name, mode_t mode);
void rmdir();
private:
DISALLOW_COPY_AND_ASSIGN(CryDir);
};