mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-12-05 03:33:27 +01: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) {
|
||||
// TODO: fix leading '/'
|
||||
|
||||
std::string_view pstr {path};
|
||||
//for (auto&[str, data] : _storage) {
|
||||
for (auto& it : _storage) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -296,11 +296,13 @@ nlohmann::json FilesystemService::readJson(fs_file_t file) const {
|
||||
std::string 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 {
|
||||
if (!exists(filepath)) {
|
||||
if (!isFile(filepath)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ TEST(fs_service_system, read_const_json) {
|
||||
ASSERT_TRUE(j.empty());
|
||||
}
|
||||
|
||||
FS_CONST_MOUNT_FILE("json/file1.json",
|
||||
FS_CONST_MOUNT_FILE("/json/file1.json",
|
||||
R"({
|
||||
"answer": {
|
||||
"everything": 42
|
||||
|
Loading…
Reference in New Issue
Block a user