if (!instance.Create(LoginKey, RadioName, KeyId, AccessKey, {})) {
std::cerr << "Failed to create the processing instance" << std::endl;
return 1;
}
public:
bool SetupPath(
const std::filesystem::path& a_preset_path)
{
m_preset_path=a_preset_path;
std::error_code ec;
if ( !std::filesystem::exists(m_preset_path,ec ) ) {
return false;
}
if ( !std::filesystem::is_directory(m_preset_path, ec) ) {
return false;
}
return true;
}
virtual bool IsReadOnly()
override {
return false; };
virtual bool Exists(
const std::filesystem::path &name)
override
{
std::error_code ec;
return std::filesystem::exists(GetRealPath(name), ec);
}
virtual bool Remove(
const std::filesystem::path &name)
override
{
std::error_code ec;
return std::filesystem::remove(GetRealPath(name), ec);
}
virtual bool Rename(
const std::filesystem::path &from,
const std::filesystem::path &to)
override
{
std::error_code ec;
std::filesystem::rename(GetRealPath(from), GetRealPath(to), ec);
return (!ec);
}
virtual std::vector<std::filesystem::path>
GetAll()
override
{
std::vector<std::filesystem::path> list;
std::error_code ec;
for (auto it = std::filesystem::directory_iterator(m_preset_path.c_str(), std::filesystem::directory_options::skip_permission_denied, ec);
!ec && it != std::filesystem::directory_iterator{};
it.increment(ec) )
{
if (it->is_regular_file(ec)) {
list.push_back(it->path().lexically_relative(m_preset_path));
}
}
return list;
}
virtual std::string
Read(
const std::filesystem::path &filename)
override
{
std::ifstream f(GetRealPath(filename));
if ( f.fail() ) {
return std::string();
}
std::ostringstream ss;
ss << f.rdbuf();
return ss.str();
}
virtual bool Write(
const std::filesystem::path &filename,
const std::string &content)
override
{
std::ofstream f(GetRealPath(filename));
if ( f.fail() ) {
return false;
}
f << content;
if ( f.fail() ) {
return false;
}
return true;
}
private:
std::filesystem::path m_preset_path;
std::filesystem::path GetRealPath(const std::filesystem::path &name)
{
return m_preset_path / name;
}
};
virtual bool Rename(const std::filesystem::path &from, const std::filesystem::path &to) override
virtual ~MyPresetManager()=default
virtual bool Exists(const std::filesystem::path &name) override
virtual bool IsReadOnly() override
virtual bool Write(const std::filesystem::path &filename, const std::string &content) override
MyPresetManager()=default
virtual bool Remove(const std::filesystem::path &name) override
virtual std::vector< std::filesystem::path > GetAll() override
virtual std::string Read(const std::filesystem::path &filename) override
bool SetupPath(const std::filesystem::path &a_preset_path)
Custom preset handler helper.