1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-11-24 13:17:41 +00:00

Add delegate to validate on a file-by-file basis.

This commit is contained in:
Thomas Harte
2025-11-23 12:11:47 -05:00
parent e9ba1c4ede
commit 5c20fcefc4
2 changed files with 21 additions and 1 deletions

View File

@@ -26,11 +26,23 @@ std::optional<std::string> LocalFSFileBundle::key_file() {
return key_file_;
}
void LocalFSFileBundle::set_permission_delegate(PermissionDelegate *const delegate) {
permission_delegate_ = delegate;
}
Storage::FileHolder LocalFSFileBundle::open(const std::string &name, const Storage::FileMode mode) {
return Storage::FileHolder(base_path_ + name, mode);
const auto full_name = base_path_ + name;
if(permission_delegate_) {
permission_delegate_->validate_open(full_name, mode);
}
return Storage::FileHolder(full_name, mode);
}
bool LocalFSFileBundle::erase(const std::string &name) {
const auto full_name = base_path_ + name;
if(permission_delegate_) {
permission_delegate_->validate_erase(full_name);
}
return !remove((base_path_ + name).c_str());
}