rename 'files' to 'io'
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "coders/json.hpp"
|
||||
#include "core_defs.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
#include "files/files.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "items/ItemDef.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
#include "objects/rigging.hpp"
|
||||
@@ -54,8 +54,8 @@ static void detect_defs(
|
||||
if (name[0] == '_') {
|
||||
continue;
|
||||
}
|
||||
if (fs::is_regular_file(file) && files::is_data_file(file)) {
|
||||
auto map = files::read_object(file);
|
||||
if (fs::is_regular_file(file) && io::is_data_file(file)) {
|
||||
auto map = io::read_object(file);
|
||||
std::string id = prefix.empty() ? name : prefix + ":" + name;
|
||||
detected.emplace_back(id);
|
||||
} else if (fs::is_directory(file) &&
|
||||
@@ -78,9 +78,9 @@ static void detect_defs_pairs(
|
||||
if (name[0] == '_') {
|
||||
continue;
|
||||
}
|
||||
if (fs::is_regular_file(file) && files::is_data_file(file)) {
|
||||
if (fs::is_regular_file(file) && io::is_data_file(file)) {
|
||||
try {
|
||||
auto map = files::read_object(file);
|
||||
auto map = io::read_object(file);
|
||||
auto id = prefix.empty() ? name : prefix + ":" + name;
|
||||
auto caption = util::id_to_caption(id);
|
||||
map.at("caption").get(caption);
|
||||
@@ -147,7 +147,7 @@ void ContentLoader::fixPackIndices() {
|
||||
|
||||
dv::value root;
|
||||
if (fs::is_regular_file(contentFile)) {
|
||||
root = files::read_json(contentFile);
|
||||
root = io::read_json(contentFile);
|
||||
} else {
|
||||
root = dv::object();
|
||||
}
|
||||
@@ -159,7 +159,7 @@ void ContentLoader::fixPackIndices() {
|
||||
|
||||
if (modified) {
|
||||
// rewrite modified json
|
||||
files::write_json(contentFile, root);
|
||||
io::write_json(contentFile, root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ static void process_method(
|
||||
void ContentLoader::loadBlock(
|
||||
Block& def, const std::string& name, const fs::path& file
|
||||
) {
|
||||
auto root = files::read_json(file);
|
||||
auto root = io::read_json(file);
|
||||
if (def.properties == nullptr) {
|
||||
def.properties = dv::object();
|
||||
def.properties["name"] = name;
|
||||
@@ -404,7 +404,7 @@ void ContentLoader::loadBlock(
|
||||
void ContentLoader::loadItem(
|
||||
ItemDef& def, const std::string& name, const fs::path& file
|
||||
) {
|
||||
auto root = files::read_json(file);
|
||||
auto root = io::read_json(file);
|
||||
def.properties = root;
|
||||
|
||||
if (root.has("parent")) {
|
||||
@@ -448,7 +448,7 @@ void ContentLoader::loadItem(
|
||||
void ContentLoader::loadEntity(
|
||||
EntityDef& def, const std::string& name, const fs::path& file
|
||||
) {
|
||||
auto root = files::read_json(file);
|
||||
auto root = io::read_json(file);
|
||||
|
||||
if (root.has("parent")) {
|
||||
const auto& parentName = root["parent"].asString();
|
||||
@@ -568,7 +568,7 @@ static std::tuple<std::string, std::string, std::string> create_unit_id(
|
||||
void ContentLoader::loadBlockMaterial(
|
||||
BlockMaterial& def, const fs::path& file
|
||||
) {
|
||||
auto root = files::read_json(file);
|
||||
auto root = io::read_json(file);
|
||||
root.at("steps-sound").get(def.stepsSound);
|
||||
root.at("place-sound").get(def.placeSound);
|
||||
root.at("break-sound").get(def.breakSound);
|
||||
@@ -580,7 +580,7 @@ void ContentLoader::loadContent(const dv::value& root) {
|
||||
auto configFile = pack->folder / fs::path(prefix + "/" + name + ".json");
|
||||
std::string parent;
|
||||
if (fs::exists(configFile)) {
|
||||
auto root = files::read_json(configFile);
|
||||
auto root = io::read_json(configFile);
|
||||
root.at("parent").get(parent);
|
||||
}
|
||||
return parent;
|
||||
@@ -778,7 +778,7 @@ void ContentLoader::load() {
|
||||
// Load pack resources.json
|
||||
fs::path resourcesFile = folder / fs::u8path("resources.json");
|
||||
if (fs::exists(resourcesFile)) {
|
||||
auto resRoot = files::read_json(resourcesFile);
|
||||
auto resRoot = io::read_json(resourcesFile);
|
||||
for (const auto& [key, arr] : resRoot.asObject()) {
|
||||
if (auto resType = ResourceType_from(key)) {
|
||||
loadResources(*resType, arr);
|
||||
@@ -792,7 +792,7 @@ void ContentLoader::load() {
|
||||
// Load pack resources aliases
|
||||
fs::path aliasesFile = folder / fs::u8path("resource-aliases.json");
|
||||
if (fs::exists(aliasesFile)) {
|
||||
auto resRoot = files::read_json(aliasesFile);
|
||||
auto resRoot = io::read_json(aliasesFile);
|
||||
for (const auto& [key, arr] : resRoot.asObject()) {
|
||||
if (auto resType = ResourceType_from(key)) {
|
||||
loadResourceAliases(*resType, arr);
|
||||
@@ -821,7 +821,7 @@ void ContentLoader::load() {
|
||||
fs::path skeletonsDir = folder / fs::u8path("skeletons");
|
||||
foreach_file(skeletonsDir, [this](const fs::path& file) {
|
||||
std::string name = pack->id + ":" + file.stem().u8string();
|
||||
std::string text = files::read_string(file);
|
||||
std::string text = io::read_string(file);
|
||||
builder.add(
|
||||
rigging::SkeletonConfig::parse(text, file.u8string(), name)
|
||||
);
|
||||
@@ -830,7 +830,7 @@ void ContentLoader::load() {
|
||||
// Process content.json and load defined content units
|
||||
auto contentFile = pack->getContentFile();
|
||||
if (fs::exists(contentFile)) {
|
||||
loadContent(files::read_json(contentFile));
|
||||
loadContent(io::read_json(contentFile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "coders/json.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "data/dv.hpp"
|
||||
#include "files/engine_paths.hpp"
|
||||
#include "files/files.hpp"
|
||||
#include "io/engine_paths.hpp"
|
||||
#include "io/io.hpp"
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@@ -71,7 +71,7 @@ static void checkContentPackId(const std::string& id, const fs::path& folder) {
|
||||
}
|
||||
|
||||
ContentPack ContentPack::read(const std::string& path, const fs::path& folder) {
|
||||
auto root = files::read_json(folder / fs::path(PACKAGE_FILENAME));
|
||||
auto root = io::read_json(folder / fs::path(PACKAGE_FILENAME));
|
||||
ContentPack pack;
|
||||
root.at("id").get(pack.id);
|
||||
root.at("title").get(pack.title);
|
||||
@@ -151,7 +151,7 @@ std::vector<std::string> ContentPack::worldPacksList(const fs::path& folder) {
|
||||
if (!fs::is_regular_file(listfile)) {
|
||||
throw std::runtime_error("missing file 'packs.list'");
|
||||
}
|
||||
return files::read_list(listfile);
|
||||
return io::read_list(listfile);
|
||||
}
|
||||
|
||||
fs::path ContentPack::findPack(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "coders/json.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "files/files.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "items/ItemDef.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "world/World.hpp"
|
||||
@@ -75,7 +75,7 @@ std::shared_ptr<ContentReport> ContentReport::create(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto root = files::read_json(filename);
|
||||
auto root = io::read_json(filename);
|
||||
uint regionsVersion = 2U; // old worlds compatibility (pre 0.23)
|
||||
root.at("region-version").get(regionsVersion);
|
||||
auto& blocklist = root["blocks"];
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "../ContentPack.hpp"
|
||||
|
||||
#include "files/files.hpp"
|
||||
#include "files/engine_paths.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "io/engine_paths.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
#include "world/generator/GeneratorDef.hpp"
|
||||
#include "world/generator/VoxelFragment.hpp"
|
||||
@@ -146,7 +146,7 @@ static std::vector<std::unique_ptr<VoxelStructure>> load_structures(
|
||||
structFile.u8string());
|
||||
}
|
||||
auto fragment = std::make_unique<VoxelFragment>();
|
||||
fragment->deserialize(files::read_binary_json(structFile));
|
||||
fragment->deserialize(io::read_binary_json(structFile));
|
||||
logger.info() << "fragment " << name << " has size [" <<
|
||||
fragment->getSize().x << ", " << fragment->getSize().y << ", " <<
|
||||
fragment->getSize().z << "]";
|
||||
@@ -202,7 +202,7 @@ void ContentLoader::loadGenerator(
|
||||
if (!fs::exists(generatorFile)) {
|
||||
return;
|
||||
}
|
||||
auto map = files::read_toml(generatorsDir / fs::u8path(name + ".toml"));
|
||||
auto map = io::read_toml(generatorsDir / fs::u8path(name + ".toml"));
|
||||
map.at("caption").get(def.caption);
|
||||
map.at("biome-parameters").get(def.biomeParameters);
|
||||
map.at("biome-bpd").get(def.biomesBPD);
|
||||
|
||||
Reference in New Issue
Block a user