Initial commit

This commit is contained in:
2024-12-02 06:30:40 +00:00
commit fd62fb822d
33 changed files with 1972 additions and 0 deletions

24
include/cmd/cmd_touch.hpp Normal file
View File

@ -0,0 +1,24 @@
#pragma once
#include "cmd/cmd_base.hpp"
namespace fsh {
class CmdTouch : public Command {
protected:
virtual void register_flags() override {
ArgFactory& factory = get_factory();
factory.add_rule<std::string>(true);
}
virtual void run(std::istream& in, std::ostream& out, ArgManager& args) override {
auto name = *(args.get<std::string>(0));
if(std::ifstream(name, std::ios::in).good() || !std::ofstream(name, std::ios::out).is_open()) {
throw std::runtime_error("File exists");
}
}
};
}