rename 'files' to 'io'

This commit is contained in:
MihailRis
2025-01-30 16:53:52 +03:00
parent e5d558d357
commit 1e22882284
45 changed files with 157 additions and 160 deletions
+3 -3
View File
@@ -61,7 +61,7 @@ void World::writeResources(const Content& content) {
}
}
}
files::write_json(wfile->getResourcesFile(), root);
io::write_json(wfile->getResourcesFile(), root);
}
void World::write(Level* level) {
@@ -70,7 +70,7 @@ void World::write(Level* level) {
wfile->write(this, &content);
auto playerFile = level->players->serialize();
files::write_json(wfile->getPlayerFile(), playerFile);
io::write_json(wfile->getPlayerFile(), playerFile);
writeResources(content);
}
@@ -134,7 +134,7 @@ std::unique_ptr<Level> World::load(
logger.warning() << "player.json does not exists";
level->players->create();
} else {
auto playerRoot = files::read_json(file);
auto playerRoot = io::read_json(file);
level->players->deserialize(playerRoot);
if (!playerRoot["players"].empty()) {
+5 -5
View File
@@ -8,7 +8,7 @@
#include "content/ContentReport.hpp"
#include "compatibility.hpp"
#include "debug/Logger.hpp"
#include "files/files.hpp"
#include "io/io.hpp"
#include "objects/Player.hpp"
#include "util/ThreadPool.hpp"
#include "voxels/Chunk.hpp"
@@ -185,9 +185,9 @@ void WorldConverter::upgradeRegion(
const fs::path& file, int x, int z, RegionLayerIndex layer
) const {
auto path = wfile->getRegions().getRegionFilePath(layer, x, z);
auto bytes = files::read_bytes_buffer(path);
auto bytes = io::read_bytes_buffer(path);
auto buffer = compatibility::convert_region_2to3(bytes, layer);
files::write_bytes(path, buffer.data(), buffer.size());
io::write_bytes(path, buffer.data(), buffer.size());
}
void WorldConverter::convertVoxels(const fs::path& file, int x, int z) const {
@@ -208,9 +208,9 @@ void WorldConverter::convertInventories(const fs::path& file, int x, int z) cons
void WorldConverter::convertPlayer(const fs::path& file) const {
logger.info() << "converting player " << file.u8string();
auto map = files::read_json(file);
auto map = io::read_json(file);
Player::convert(map, report.get());
files::write_json(file, map);
io::write_json(file, map);
}
void WorldConverter::convertBlocksData(int x, int z, const ContentReport& report) const {
+9 -9
View File
@@ -100,7 +100,7 @@ void WorldFiles::writePacks(const std::vector<ContentPack>& packs) {
for (const auto& pack : packs) {
ss << pack.id << "\n";
}
files::write_string(packsFile, ss.str());
io::write_string(packsFile, ss.str());
}
template <class T>
@@ -139,11 +139,11 @@ void WorldFiles::writeIndices(const ContentIndices* indices) {
createContentIndicesCache(indices, root);
createBlockFieldsIndices(indices, root);
files::write_json(getIndicesFile(), root);
io::write_json(getIndicesFile(), root);
}
void WorldFiles::writeWorldInfo(const WorldInfo& info) {
files::write_json(getWorldFile(), info.serialize());
io::write_json(getWorldFile(), info.serialize());
}
std::optional<WorldInfo> WorldFiles::readWorldInfo() {
@@ -152,7 +152,7 @@ std::optional<WorldInfo> WorldFiles::readWorldInfo() {
logger.warning() << "world.json does not exists";
return std::nullopt;
}
auto root = files::read_json(file);
auto root = io::read_json(file);
WorldInfo info {};
info.deserialize(root);
return info;
@@ -180,7 +180,7 @@ bool WorldFiles::readResourcesData(const Content& content) {
logger.warning() << "resources.json does not exists";
return false;
}
auto root = files::read_json(file);
auto root = io::read_json(file);
for (const auto& [key, arr] : root.asObject()) {
if (auto resType = ResourceType_from(key)) {
read_resources_data(content, arr, *resType);
@@ -197,12 +197,12 @@ void WorldFiles::patchIndicesFile(const dv::value& map) {
logger.error() << file.filename().u8string() << " does not exists";
return;
}
auto root = files::read_json(file);
auto root = io::read_json(file);
for (const auto& [key, value] : map.asObject()) {
logger.info() << "patching indices.json: update " << util::quote(key);
root[key] = value;
}
files::write_json(file, root, true);
io::write_json(file, root, true);
}
static void erase_pack_indices(dv::value& root, const std::string& id) {
@@ -223,11 +223,11 @@ static void erase_pack_indices(dv::value& root, const std::string& id) {
}
void WorldFiles::removeIndices(const std::vector<std::string>& packs) {
auto root = files::read_json(getIndicesFile());
auto root = io::read_json(getIndicesFile());
for (const auto& id : packs) {
erase_pack_indices(root, id);
}
files::write_json(getIndicesFile(), root);
io::write_json(getIndicesFile(), root);
}
fs::path WorldFiles::getFolder() const {
+1 -1
View File
@@ -11,7 +11,7 @@
#include "typedefs.hpp"
#include "voxels/Chunk.hpp"
#include "WorldRegions.hpp"
#include "files/files.hpp"
#include "io/io.hpp"
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/hash.hpp>
+2 -2
View File
@@ -13,7 +13,7 @@
#include "voxels/Chunk.hpp"
#include "maths/voxmaths.hpp"
#include "coders/compression.hpp"
#include "files/files.hpp"
#include "io/io.hpp"
#include "world_regions_fwd.hpp"
#define GLM_ENABLE_EXPERIMENTAL
@@ -54,7 +54,7 @@ public:
};
struct regfile {
files::rafile file;
io::rafile file;
int version;
bool inUse = false;