mirror of
https://github.com/TomHarte/CLK.git
synced 2025-11-25 04:18:05 +00:00
Implement destroy channel.
This commit is contained in:
@@ -128,6 +128,17 @@ void HostFSHandler::perform(const uint8_t function, uint8_t &a, uint16_t &bc, ui
|
||||
channels_.erase(channel);
|
||||
break;
|
||||
|
||||
// Page 54.
|
||||
case uint8_t(EXOS::Function::DestroyChannel): {
|
||||
const auto name = file.name();
|
||||
channels_.erase(channel);
|
||||
if(bundle_->erase(name)) {
|
||||
set_error(EXOS::Error::NoError);
|
||||
} else {
|
||||
set_error(EXOS::Error::ProtectionViolation);
|
||||
}
|
||||
} break;
|
||||
|
||||
// Page 55.
|
||||
case uint8_t(EXOS::Function::ReadCharacter): {
|
||||
const auto next = file.get();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "FileBundle.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
using namespace Storage::FileBundle;
|
||||
|
||||
LocalFSFileBundle::LocalFSFileBundle(const std::string &to_contain) {
|
||||
@@ -27,3 +29,7 @@ std::optional<std::string> LocalFSFileBundle::key_file() {
|
||||
Storage::FileHolder LocalFSFileBundle::open(const std::string &name, const Storage::FileMode mode) {
|
||||
return Storage::FileHolder(base_path_ + name, mode);
|
||||
}
|
||||
|
||||
bool LocalFSFileBundle::erase(const std::string &name) {
|
||||
return !remove((base_path_ + name).c_str());
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Storage::FileBundle {
|
||||
struct FileBundle {
|
||||
virtual std::optional<std::string> key_file() = 0;
|
||||
virtual FileHolder open(const std::string &, FileMode) = 0;
|
||||
virtual bool erase(const std::string &) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +34,7 @@ struct LocalFSFileBundle: public FileBundle {
|
||||
|
||||
std::optional<std::string> key_file() override;
|
||||
FileHolder open(const std::string &, FileMode) override;
|
||||
bool erase(const std::string &) override;
|
||||
|
||||
private:
|
||||
std::string key_file_;
|
||||
|
||||
Reference in New Issue
Block a user