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