2018-10-06 20:37:09 -07:00
|
|
|
#pragma once
|
2015-05-18 14:03:13 -07:00
|
|
|
|
2019-08-26 04:06:18 -07:00
|
|
|
#include <string>
|
2015-05-18 14:03:13 -07:00
|
|
|
|
2015-06-19 21:40:15 -07:00
|
|
|
#if _WIN32
|
2019-08-26 04:06:18 -07:00
|
|
|
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 {
|
2015-05-18 14:03:13 -07:00
|
|
|
public:
|
2018-12-07 21:18:17 -08:00
|
|
|
explicit Dir(std::string_view path);
|
2015-05-18 14:03:13 -07:00
|
|
|
|
2018-12-07 21:18:17 -08:00
|
|
|
std::string absolutePath() const;
|
2019-08-15 05:46:55 -07:00
|
|
|
static std::string absolutePath(std::string_view path) { return Dir(path).absolutePath(); }
|
2015-05-18 14:03:13 -07:00
|
|
|
|
2018-12-07 21:18:17 -08:00
|
|
|
bool isDir() const;
|
|
|
|
static bool isDir(std::string_view dir) { return Dir(dir).isDir(); }
|
2015-05-18 14:03:13 -07:00
|
|
|
|
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);
|
2015-05-18 14:03:13 -07:00
|
|
|
|
|
|
|
private:
|
2018-12-07 21:18:17 -08:00
|
|
|
std::string m_path;
|
2015-05-18 14:03:13 -07:00
|
|
|
};
|
2018-12-07 21:18:17 -08:00
|
|
|
} // namespace athena
|