rmdir
This commit is contained in:
parent
afd4066ef7
commit
8561d90de0
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user