finish manager split
This commit is contained in:
@ -143,6 +143,8 @@ namespace LibCmo::CK2::MgrImpls {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CKDWORD CKObjectManager::AllocateGroupGlobalIndex(ObjImpls::CKObject* group) {
|
||||
|
@ -40,6 +40,13 @@ namespace LibCmo::CK2::MgrImpls {
|
||||
|
||||
// ========== Objects Access ==========
|
||||
|
||||
/**
|
||||
* @brief General object list query.
|
||||
* @param name nullptr if no requirement.
|
||||
* @param cid the class id
|
||||
* @param derived whether considering derived class
|
||||
* @return the result pointer list.
|
||||
*/
|
||||
XContainer::XObjectPointerArray GetObjectByNameAndClass(
|
||||
CKSTRING name, CK_CLASSID cid, bool derived);
|
||||
|
||||
|
@ -2,5 +2,49 @@
|
||||
|
||||
namespace LibCmo::CK2::MgrImpls {
|
||||
|
||||
#if defined(LIBCMO_OS_WIN32)
|
||||
static wchar_t g_UniqueFolder[] = L"LibCmo";
|
||||
#else
|
||||
static char g_UniqueFolder[] = "LibCmo";
|
||||
#endif
|
||||
|
||||
CKPathManager::CKPathManager(CKContext* ctx) :
|
||||
CKBaseManager(ctx, PATH_MANAGER_GUID, "Path Manager"),
|
||||
m_TempFolder() {
|
||||
// preset for temp folder
|
||||
// todo: add current CKContext pointer as the part of temp path.
|
||||
// thus multiple CKContext can work.
|
||||
m_TempFolder = std::filesystem::temp_directory_path();
|
||||
m_TempFolder /= g_UniqueFolder;
|
||||
std::filesystem::create_directories(m_TempFolder);
|
||||
|
||||
}
|
||||
CKPathManager::~CKPathManager() {}
|
||||
|
||||
void CKPathManager::SetTempFolder(CKSTRING u8_temp) {
|
||||
EncodingHelper::U8PathToStdPath(this->m_TempFolder, u8_temp);
|
||||
}
|
||||
|
||||
std::string CKPathManager::GetTempFolder() {
|
||||
std::string result;
|
||||
EncodingHelper::StdPathToU8Path(result, this->m_TempFolder);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string CKPathManager::GetTempFilePath(CKSTRING u8_filename) {
|
||||
std::filesystem::path stdfilename;
|
||||
EncodingHelper::U8PathToStdPath(stdfilename, u8_filename);
|
||||
auto realfile = this->m_TempFolder / stdfilename;
|
||||
|
||||
std::string result;
|
||||
EncodingHelper::StdPathToU8Path(result, realfile);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CKPathManager::ResolveFileName(std::string& u8_filename) {
|
||||
// todo: finish resolve file name
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,18 +2,42 @@
|
||||
|
||||
#include "../../VTAll.hpp"
|
||||
#include "CKBaseManager.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
namespace LibCmo::CK2::MgrImpls {
|
||||
|
||||
class CKPathManager : public CKBaseManager {
|
||||
public:
|
||||
CKPathManager(CKContext* ctx) :
|
||||
CKBaseManager(ctx, PATH_MANAGER_GUID, "Path Manager") {}
|
||||
virtual ~CKPathManager() {}
|
||||
CKPathManager(CKContext* ctx);
|
||||
virtual ~CKPathManager();
|
||||
LIBCMO_DISABLE_COPY_MOVE(CKPathManager);
|
||||
|
||||
/**
|
||||
* @brief Set the temp folder of current context.
|
||||
* @param u8_temp
|
||||
*/
|
||||
void SetTempFolder(CKSTRING u8_temp);
|
||||
/**
|
||||
* @brief Get current temp folder.
|
||||
* @return
|
||||
*/
|
||||
std::string GetTempFolder();
|
||||
/**
|
||||
* @brief Get the path of temp file.
|
||||
* @param u8_filename The relative path of file.
|
||||
* @return The path of given path based on temp folder.
|
||||
*/
|
||||
std::string GetTempFilePath(CKSTRING u8_filename);
|
||||
|
||||
/**
|
||||
* @brief Finds a file in the paths
|
||||
* @param u8_filename[inout] The given file path. overwritten by the final path if success.
|
||||
* @return true if success
|
||||
*/
|
||||
bool ResolveFileName(std::string& u8_filename);
|
||||
|
||||
protected:
|
||||
|
||||
std::filesystem::path m_TempFolder;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user