This commit is contained in:
Sebastian Messmer 2014-11-12 12:31:38 +01:00
parent c112def985
commit afd4066ef7
5 changed files with 18 additions and 4 deletions

View File

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

View File

@ -111,3 +111,8 @@ void CryDevice::mkdir(const bf::path &path, mode_t mode) {
auto dir = LoadDir(path.parent_path());
dir->createDir(path.filename().native(), mode);
}
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 unlink(const bf::path &path);
const bf::path &RootDir() const;
private:

View File

@ -25,4 +25,9 @@ void CryFile::truncate(off_t size) const {
CHECK_RETVAL(retval);
}
void CryFile::unlink() {
int retval = ::unlink(base_path().c_str());
CHECK_RETVAL(retval);
}
} /* namespace cryfs */

View File

@ -18,6 +18,7 @@ public:
std::unique_ptr<CryOpenFile> open(int flags) const;
void truncate(off_t size) const;
void unlink();
private:
DISALLOW_COPY_AND_ASSIGN(CryFile);
};