Files
fsh-oop/include/cmd/cmd_touch.hpp
2025-08-29 00:02:45 +02:00

23 lines
607 B
C++

#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 util::FileExistsError();
}
}
};
}