athena/include/athena/Dir.hpp

32 lines
673 B
C++
Raw Normal View History

2018-10-06 20:37:09 -07:00
#pragma once
#include <string>
2015-06-19 21:40:15 -07:00
#if _WIN32
using mode_t = int;
2022-08-03 15:16:30 -07:00
#else
#include <sys/stat.h>
2015-06-19 21:40:15 -07:00
#endif
2018-12-07 21:18:17 -08:00
namespace athena {
class Dir {
public:
2018-12-07 21:18:17 -08:00
explicit Dir(std::string_view path);
2018-12-07 21:18:17 -08:00
std::string absolutePath() const;
static std::string absolutePath(std::string_view path) { return Dir(path).absolutePath(); }
2018-12-07 21:18:17 -08:00
bool isDir() const;
static bool isDir(std::string_view dir) { return Dir(dir).isDir(); }
2018-12-07 21:18:17 -08:00
bool cd(std::string_view path);
bool rm(std::string_view path);
bool touch();
static bool mkdir(std::string_view dir, mode_t mode = 0755);
static bool mkpath(std::string_view path, mode_t mode = 0755);
private:
2018-12-07 21:18:17 -08:00
std::string m_path;
};
2018-12-07 21:18:17 -08:00
} // namespace athena