write garbage

- fix PathManager nullptr assign issue
- fix Context set encoding unexpected copy issue
- write some export function for BMap.
This commit is contained in:
2023-09-23 16:25:26 +08:00
parent 94dadbfb1f
commit a17b9deb4c
7 changed files with 81 additions and 15 deletions

View File

@ -309,7 +309,7 @@ namespace LibCmo::CK2 {
}
}
void CKContext::SetEncoding(const XContainer::XArray<XContainer::XString> encoding_series) {
void CKContext::SetEncoding(const XContainer::XArray<XContainer::XString>& encoding_series) {
// free all current series
for (const auto& encoding : this->m_NameEncoding) {
LibCmo::EncodingHelper::DestroyEncodingToken(encoding);

View File

@ -102,7 +102,7 @@ namespace LibCmo::CK2 {
public:
void GetUtf8String(const XContainer::XString& native_name, XContainer::XString& u8_name);
void GetNativeString(const XContainer::XString& u8_name, XContainer::XString& native_name);
void SetEncoding(const XContainer::XArray<XContainer::XString> encoding_series);
void SetEncoding(const XContainer::XArray<XContainer::XString>& encoding_series);
protected:
XContainer::XArray<EncodingHelper::ENCODING_TOKEN> m_NameEncoding;

View File

@ -22,6 +22,8 @@ namespace LibCmo::CK2::MgrImpls {
CKPathManager::~CKPathManager() {}
bool CKPathManager::SetTempFolder(CKSTRING u8_temp) {
if (u8_temp == nullptr) return false;
std::filesystem::path cache;
EncodingHelper::U8PathToStdPath(cache, u8_temp);
if (std::filesystem::is_directory(cache)) {
@ -39,6 +41,8 @@ namespace LibCmo::CK2::MgrImpls {
}
XContainer::XString CKPathManager::GetTempFilePath(CKSTRING u8_filename) {
if (u8_filename == nullptr) return XContainer::XString();
std::filesystem::path stdfilename;
EncodingHelper::U8PathToStdPath(stdfilename, u8_filename);
auto realfile = this->m_TempFolder / stdfilename;
@ -50,6 +54,7 @@ namespace LibCmo::CK2::MgrImpls {
bool CKPathManager::AddPath(CKSTRING u8path) {
if (u8path == nullptr) return false;
std::filesystem::path newpath;
EncodingHelper::U8PathToStdPath(newpath, u8path);
if (std::filesystem::is_directory(newpath)) {