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
@@ -7,9 +7,9 @@
#include "content/Content.hpp"
#include "debug/Logger.hpp"
#include "engine/Engine.hpp"
#include "files/engine_paths.hpp"
#include "files/files.hpp"
#include "files/settings_io.hpp"
#include "io/engine_paths.hpp"
#include "io/io.hpp"
#include "io/settings_io.hpp"
#include "frontend/menu.hpp"
#include "frontend/screens/MenuScreen.hpp"
#include "graphics/core/Texture.hpp"
+7 -7
View File
@@ -4,8 +4,8 @@
#include "coders/gzip.hpp"
#include "engine/Engine.hpp"
#include "files/engine_paths.hpp"
#include "files/files.hpp"
#include "io/engine_paths.hpp"
#include "io/io.hpp"
#include "util/stringutil.hpp"
#include "api_lua.hpp"
#include "../lua_engine.hpp"
@@ -41,7 +41,7 @@ static int l_resolve(lua::State* L) {
static int l_read(lua::State* L) {
fs::path path = resolve_path(lua::require_string(L, 1));
if (fs::is_regular_file(path)) {
return lua::pushstring(L, files::read_string(path));
return lua::pushstring(L, io::read_string(path));
}
throw std::runtime_error(
"file does not exists " + util::quote(path.u8string())
@@ -65,7 +65,7 @@ static fs::path get_writeable_path(lua::State* L) {
static int l_write(lua::State* L) {
fs::path path = get_writeable_path(L);
std::string text = lua::require_string(L, 2);
files::write_string(path, text);
io::write_string(path, text);
return 1;
}
@@ -128,7 +128,7 @@ static int l_read_bytes(lua::State* L) {
if (fs::is_regular_file(path)) {
size_t length = static_cast<size_t>(fs::file_size(path));
auto bytes = files::read_bytes(path, length);
auto bytes = io::read_bytes(path, length);
lua::createtable(L, length, 0);
int newTable = lua::gettop(L);
@@ -150,14 +150,14 @@ static int l_write_bytes(lua::State* L) {
if (auto bytearray = lua::touserdata<lua::LuaBytearray>(L, 2)) {
auto& bytes = bytearray->data();
return lua::pushboolean(
L, files::write_bytes(path, bytes.data(), bytes.size())
L, io::write_bytes(path, bytes.data(), bytes.size())
);
}
std::vector<ubyte> bytes;
lua::read_bytes_from_table(L, 2, bytes);
return lua::pushboolean(
L, files::write_bytes(path, bytes.data(), bytes.size())
L, io::write_bytes(path, bytes.data(), bytes.size())
);
}
@@ -1,7 +1,7 @@
#include "api_lua.hpp"
#include "files/files.hpp"
#include "files/util.hpp"
#include "io/io.hpp"
#include "io/util.hpp"
#include "coders/binary_json.hpp"
#include "world/Level.hpp"
#include "world/generator/VoxelFragment.hpp"
@@ -17,7 +17,7 @@ static int l_save_fragment(lua::State* L) {
auto file = paths.resolve(lua::require_string(L, 2), true);
auto map = fragment->getFragment()->serialize();
auto bytes = json::to_binary(map, true);
files::write_bytes(file, bytes.data(), bytes.size());
io::write_bytes(file, bytes.data(), bytes.size());
return 0;
}
@@ -41,7 +41,7 @@ static int l_load_fragment(lua::State* L) {
if (!std::filesystem::exists(path)) {
throw std::runtime_error("file "+path.u8string()+" does not exist");
}
auto map = files::read_binary_json(path);
auto map = io::read_binary_json(path);
auto fragment = std::make_shared<VoxelFragment>();
fragment->deserialize(map);
+2 -2
View File
@@ -1,7 +1,7 @@
#include <filesystem>
#include "engine/Engine.hpp"
#include "files/files.hpp"
#include "io/io.hpp"
#include "frontend/hud.hpp"
#include "frontend/screens/Screen.hpp"
#include "graphics/ui/GUI.hpp"
@@ -141,7 +141,7 @@ static void resetPackBindings(fs::path& packFolder) {
if (fs::is_regular_file(bindsFile)) {
Events::loadBindings(
bindsFile.u8string(),
files::read_string(bindsFile),
io::read_string(bindsFile),
BindType::REBIND
);
}
+1 -1
View File
@@ -8,7 +8,7 @@
#include "content/Content.hpp"
#include "engine/Engine.hpp"
#include "world/files/WorldFiles.hpp"
#include "files/engine_paths.hpp"
#include "io/engine_paths.hpp"
#include "world/Level.hpp"
#include "world/World.hpp"
#include "api_lua.hpp"
+3 -3
View File
@@ -7,8 +7,8 @@
#include "coders/json.hpp"
#include "engine/Engine.hpp"
#include "world/files/WorldFiles.hpp"
#include "files/engine_paths.hpp"
#include "files/files.hpp"
#include "io/engine_paths.hpp"
#include "io/io.hpp"
#include "lighting/Lighting.hpp"
#include "voxels/Chunk.hpp"
#include "voxels/Chunks.hpp"
@@ -44,7 +44,7 @@ static int l_get_list(lua::State* L) {
const auto& folder = worlds[i];
auto root =
json::parse(files::read_string(folder / fs::u8path("world.json")));
json::parse(io::read_string(folder / fs::u8path("world.json")));
const auto& versionMap = root["version"];
int versionMajor = versionMap["major"].asInteger();
int versionMinor = versionMap["minor"].asInteger();
+3 -3
View File
@@ -3,8 +3,8 @@
#include <iomanip>
#include <iostream>
#include "files/files.hpp"
#include "files/engine_paths.hpp"
#include "io/io.hpp"
#include "io/engine_paths.hpp"
#include "debug/Logger.hpp"
#include "util/stringutil.hpp"
#include "libs/api_lua.hpp"
@@ -161,7 +161,7 @@ State* lua::create_state(const EnginePaths& paths, StateType stateType) {
auto resDir = paths.getResourcesFolder();
auto file = resDir / fs::u8path("scripts/stdmin.lua");
auto src = files::read_string(file);
auto src = io::read_string(file);
lua::pop(L, lua::execute(L, 0, src, "core:scripts/stdmin.lua"));
return L;
}
@@ -9,7 +9,7 @@
#define FNL_IMPL
#include "maths/FastNoiseLite.h"
#include "coders/imageio.hpp"
#include "files/util.hpp"
#include "io/util.hpp"
#include "graphics/core/ImageData.hpp"
#include "maths/Heightmap.hpp"
#include "engine/Engine.hpp"
+6 -6
View File
@@ -8,8 +8,8 @@
#include "content/ContentPack.hpp"
#include "debug/Logger.hpp"
#include "engine/Engine.hpp"
#include "files/engine_paths.hpp"
#include "files/files.hpp"
#include "io/engine_paths.hpp"
#include "io/io.hpp"
#include "frontend/UiDocument.hpp"
#include "items/Inventory.hpp"
#include "items/ItemDef.hpp"
@@ -44,7 +44,7 @@ LevelController* scripting::controller = nullptr;
void scripting::load_script(const fs::path& name, bool throwable) {
const auto& paths = scripting::engine->getPaths();
fs::path file = paths.getResourcesFolder() / fs::path("scripts") / name;
std::string src = files::read_string(file);
std::string src = io::read_string(file);
auto L = lua::get_main_state();
lua::loadbuffer(L, 0, src, "core:scripts/"+name.u8string());
if (throwable) {
@@ -60,7 +60,7 @@ int scripting::load_script(
const fs::path& file,
const std::string& fileName
) {
std::string src = files::read_string(file);
std::string src = io::read_string(file);
logger.info() << "script (" << type << ") " << file.u8string();
return lua::execute(lua::get_main_state(), env, src, fileName);
}
@@ -117,7 +117,7 @@ std::unique_ptr<Process> scripting::start_coroutine(
) {
auto L = lua::get_main_state();
if (lua::getglobal(L, "__vc_start_coroutine")) {
auto source = files::read_string(script);
auto source = io::read_string(script);
lua::loadbuffer(L, 0, source, script.filename().u8string());
if (lua::call(L, 1)) {
int id = lua::tointeger(L, -1);
@@ -872,7 +872,7 @@ void scripting::load_entity_component(
const std::string& name, const fs::path& file, const std::string& fileName
) {
auto L = lua::get_main_state();
std::string src = files::read_string(file);
std::string src = io::read_string(file);
logger.info() << "script (component) " << file.u8string();
lua::loadbuffer(L, 0, src, fileName);
lua::store_in(L, lua::CHUNKS_TABLE, name);
+3 -3
View File
@@ -2,7 +2,7 @@
#include "debug/Logger.hpp"
#include "engine/Engine.hpp"
#include "files/files.hpp"
#include "io/io.hpp"
#include "frontend/hud.hpp"
#include "frontend/UiDocument.hpp"
#include "graphics/render/WorldRenderer.hpp"
@@ -20,7 +20,7 @@ WorldRenderer* scripting::renderer = nullptr;
static void load_script(const std::string& name) {
auto file = engine->getPaths().getResourcesFolder() / "scripts" / name;
std::string src = files::read_string(file);
std::string src = io::read_string(file);
logger.info() << "loading script " << file.u8string();
lua::execute(lua::get_main_state(), 0, src, file.u8string());
@@ -84,7 +84,7 @@ void scripting::load_hud_script(
const std::string& fileName
) {
int env = *senv;
std::string src = files::read_string(file);
std::string src = io::read_string(file);
logger.info() << "loading script " << file.u8string();
lua::execute(lua::get_main_state(), env, src, fileName);
@@ -13,7 +13,7 @@
#include "data/dv.hpp"
#include "world/generator/GeneratorDef.hpp"
#include "util/timeutil.hpp"
#include "files/files.hpp"
#include "io/io.hpp"
#include "engine/Engine.hpp"
#include "debug/Logger.hpp"
@@ -55,7 +55,7 @@ public:
pop(L);
if (fs::exists(file)) {
std::string src = files::read_string(file);
std::string src = io::read_string(file);
logger.info() << "script (generator) " << file.u8string();
pop(L, execute(L, *env, src, file.u8string()));
} else {