diff --git a/Machines/Enterprise/HostFSHandler.cpp b/Machines/Enterprise/HostFSHandler.cpp index 5e3b40dfe..2006a8677 100644 --- a/Machines/Enterprise/HostFSHandler.cpp +++ b/Machines/Enterprise/HostFSHandler.cpp @@ -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(); diff --git a/Storage/FileBundle/FileBundle.cpp b/Storage/FileBundle/FileBundle.cpp index 9ce9cae79..de86925be 100644 --- a/Storage/FileBundle/FileBundle.cpp +++ b/Storage/FileBundle/FileBundle.cpp @@ -8,6 +8,8 @@ #include "FileBundle.hpp" +#include + using namespace Storage::FileBundle; LocalFSFileBundle::LocalFSFileBundle(const std::string &to_contain) { @@ -27,3 +29,7 @@ std::optional 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()); +} diff --git a/Storage/FileBundle/FileBundle.hpp b/Storage/FileBundle/FileBundle.hpp index 87fe04c71..cfd94d0b6 100644 --- a/Storage/FileBundle/FileBundle.hpp +++ b/Storage/FileBundle/FileBundle.hpp @@ -25,6 +25,7 @@ namespace Storage::FileBundle { struct FileBundle { virtual std::optional 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 key_file() override; FileHolder open(const std::string &, FileMode) override; + bool erase(const std::string &) override; private: std::string key_file_;