mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
36 lines
897 B
C++
36 lines
897 B
C++
#pragma once
|
|
|
|
#include "Platform.hpp"
|
|
#include "SingletonHolder.hpp"
|
|
|
|
namespace asst
|
|
{
|
|
enum class WorkingDirType
|
|
{
|
|
Res,
|
|
User,
|
|
};
|
|
|
|
template <WorkingDirType type>
|
|
class WorkingDir : public SingletonHolder<WorkingDir<type>>
|
|
{
|
|
public:
|
|
bool empty() const noexcept { return dir_.empty(); }
|
|
const std::filesystem::path& get() const noexcept { return dir_; }
|
|
bool set(std::filesystem::path dir)
|
|
{
|
|
if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir)) {
|
|
return false;
|
|
}
|
|
dir_ = std::move(dir);
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
std::filesystem::path dir_;
|
|
};
|
|
|
|
static auto& ResDir = WorkingDir<WorkingDirType::Res>::get_instance();
|
|
static auto& UserDir = WorkingDir<WorkingDirType::User>::get_instance();
|
|
} // namespace asst
|