mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-04-16 16:32:59 +02:00
minor filesystem fixups
This commit is contained in:
parent
4f859bad2e
commit
66c7958084
@ -186,12 +186,14 @@ PHYSFS_Io* FSConstArchiver::createIO(const char* filename, PHYSFS_uint64 pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FSConstArchiver::pathIsDir(const char* path) {
|
bool FSConstArchiver::pathIsDir(const char* path) {
|
||||||
|
// TODO: fix leading '/'
|
||||||
|
|
||||||
std::string_view pstr {path};
|
std::string_view pstr {path};
|
||||||
//for (auto&[str, data] : _storage) {
|
//for (auto&[str, data] : _storage) {
|
||||||
for (auto& it : _storage) {
|
for (auto& it : _storage) {
|
||||||
// stats_with c++20 <.<
|
// stats_with c++20 <.<
|
||||||
|
|
||||||
if (it.first.compare(0, pstr.size(), pstr) == 0) {
|
if (it.first.compare(0, pstr.size(), pstr) == 0 && it.first.size() != pstr.size()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,11 +296,13 @@ nlohmann::json FilesystemService::readJson(fs_file_t file) const {
|
|||||||
std::string buffer;
|
std::string buffer;
|
||||||
readString(file, buffer);
|
readString(file, buffer);
|
||||||
|
|
||||||
return nlohmann::json::parse(buffer);
|
// disable exeptions
|
||||||
|
// TODO: use callback instead of readString()
|
||||||
|
return nlohmann::json::parse(buffer, nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json FilesystemService::readJson(const char* filepath) const {
|
nlohmann::json FilesystemService::readJson(const char* filepath) const {
|
||||||
if (!exists(filepath)) {
|
if (!isFile(filepath)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ TEST(fs_service_system, read_const_json) {
|
|||||||
ASSERT_TRUE(j.empty());
|
ASSERT_TRUE(j.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_CONST_MOUNT_FILE("json/file1.json",
|
FS_CONST_MOUNT_FILE("/json/file1.json",
|
||||||
R"({
|
R"({
|
||||||
"answer": {
|
"answer": {
|
||||||
"everything": 42
|
"everything": 42
|
||||||
|
Loading…
x
Reference in New Issue
Block a user