From 9e328bb5b7bfb30b832e9ef733e535de93e1c60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 11 Jun 2021 14:51:48 +0200 Subject: Core: Move DirAccess and FileAccess to `core/io` File handling APIs are typically considered part of I/O, and we did have most `FileAccess` implementations in `core/io` already. --- core/config/project_settings.cpp | 4 +- core/core_bind.h | 4 +- core/io/config_file.h | 2 +- core/io/dir_access.cpp | 418 +++++++++++++ core/io/dir_access.h | 147 +++++ core/io/dtls_server.cpp | 2 +- core/io/file_access.cpp | 676 +++++++++++++++++++++ core/io/file_access.h | 198 ++++++ core/io/file_access_compressed.h | 2 +- core/io/file_access_encrypted.h | 2 +- core/io/file_access_memory.cpp | 2 +- core/io/file_access_memory.h | 2 +- core/io/file_access_network.h | 2 +- core/io/file_access_pack.h | 4 +- core/io/file_access_zip.cpp | 2 +- core/io/image_loader.h | 2 +- core/io/logger.cpp | 2 +- core/io/logger.h | 2 +- core/io/packet_peer_dtls.cpp | 2 +- core/io/pck_packer.cpp | 2 +- core/io/resource.cpp | 2 +- core/io/resource_format_binary.cpp | 2 +- core/io/resource_format_binary.h | 2 +- core/io/resource_loader.cpp | 2 +- core/io/resource_saver.cpp | 2 +- core/io/translation_loader_po.cpp | 2 +- core/io/translation_loader_po.h | 2 +- core/io/xml_parser.h | 2 +- core/io/zip_io.h | 2 +- core/math/delaunay_3d.h | 2 +- core/os/dir_access.cpp | 418 ------------- core/os/dir_access.h | 147 ----- core/os/file_access.cpp | 676 --------------------- core/os/file_access.h | 198 ------ core/os/os.cpp | 4 +- core/string/translation_po.cpp | 2 +- core/variant/variant_parser.h | 2 +- drivers/png/resource_saver_png.cpp | 2 +- drivers/unix/dir_access_unix.h | 2 +- drivers/unix/file_access_unix.h | 2 +- drivers/vulkan/rendering_device_vulkan.cpp | 2 +- drivers/windows/dir_access_windows.h | 2 +- drivers/windows/file_access_windows.h | 2 +- editor/dependency_editor.cpp | 2 +- editor/doc_tools.cpp | 2 +- editor/editor_asset_installer.cpp | 4 +- editor/editor_data.cpp | 4 +- editor/editor_dir_dialog.h | 2 +- editor/editor_export.cpp | 4 +- editor/editor_export.h | 2 +- editor/editor_feature_profile.cpp | 2 +- editor/editor_feature_profile.h | 2 +- editor/editor_file_dialog.cpp | 2 +- editor/editor_file_dialog.h | 2 +- editor/editor_file_system.cpp | 2 +- editor/editor_file_system.h | 2 +- editor/editor_folding.cpp | 2 +- editor/editor_fonts.cpp | 2 +- editor/editor_node.cpp | 2 +- editor/editor_paths.cpp | 2 +- editor/editor_plugin_settings.cpp | 2 +- editor/editor_resource_preview.cpp | 2 +- editor/editor_settings.cpp | 4 +- editor/editor_translation_parser.cpp | 2 +- editor/export_template_manager.cpp | 2 +- editor/filesystem_dock.cpp | 4 +- editor/filesystem_dock.h | 2 +- editor/find_in_files.cpp | 2 +- .../import/resource_importer_csv_translation.cpp | 2 +- editor/import/resource_importer_image.cpp | 2 +- editor/import/resource_importer_obj.cpp | 2 +- editor/import/resource_importer_shader_file.cpp | 2 +- editor/import/resource_importer_texture.h | 2 +- editor/import/resource_importer_texture_atlas.cpp | 2 +- editor/import/resource_importer_wav.cpp | 2 +- editor/plugin_config_dialog.cpp | 2 +- .../plugins/collision_polygon_3d_editor_plugin.cpp | 2 +- editor/plugins/path_2d_editor_plugin.cpp | 2 +- editor/plugins/polygon_2d_editor_plugin.cpp | 2 +- editor/plugins/script_editor_plugin.cpp | 2 +- editor/plugins/theme_editor_plugin.cpp | 2 +- editor/pot_generator.h | 2 +- editor/project_export.cpp | 4 +- editor/project_export.h | 2 +- editor/project_manager.cpp | 4 +- editor/script_create_dialog.cpp | 2 +- main/main.cpp | 2 +- modules/dds/texture_loader_dds.cpp | 2 +- modules/fbx/tools/validation_tools.h | 2 +- modules/gdnative/gdnative.cpp | 4 +- modules/gdnative/nativescript/api_generator.cpp | 2 +- modules/gdnative/nativescript/nativescript.cpp | 2 +- .../pluginscript/pluginscript_language.cpp | 2 +- .../gdnative/pluginscript/pluginscript_loader.cpp | 2 +- .../gdnative/pluginscript/pluginscript_script.cpp | 2 +- modules/gdnative/pluginscript/register_types.cpp | 2 +- .../gdnative/videodecoder/video_stream_gdnative.h | 2 +- modules/gdscript/gdscript.cpp | 2 +- modules/gdscript/gdscript_analyzer.cpp | 2 +- modules/gdscript/gdscript_cache.cpp | 2 +- modules/gdscript/gdscript_editor.cpp | 2 +- modules/gdscript/gdscript_parser.cpp | 2 +- .../language_server/gdscript_language_server.cpp | 2 +- .../language_server/gdscript_text_document.h | 2 +- modules/gdscript/register_types.cpp | 4 +- modules/gdscript/tests/gdscript_test_runner.cpp | 2 +- modules/gdscript/tests/test_gdscript.cpp | 2 +- modules/gltf/editor_scene_importer_gltf.cpp | 2 +- modules/gltf/gltf_document.cpp | 2 +- modules/mbedtls/crypto_mbedtls.cpp | 2 +- modules/mbedtls/packet_peer_mbed_dtls.cpp | 2 +- modules/mbedtls/ssl_context_mbedtls.h | 2 +- modules/mbedtls/stream_peer_mbedtls.cpp | 2 +- modules/minimp3/audio_stream_mp3.cpp | 2 +- modules/minimp3/resource_importer_mp3.cpp | 2 +- modules/mono/class_db_api_json.cpp | 2 +- modules/mono/csharp_script.cpp | 2 +- modules/mono/editor/bindings_generator.cpp | 4 +- modules/mono/godotsharp_dirs.cpp | 2 +- modules/mono/mono_gd/gd_mono.cpp | 4 +- modules/mono/mono_gd/gd_mono_assembly.cpp | 2 +- modules/mono/mono_gd/gd_mono_log.cpp | 2 +- modules/mono/mono_gd/gd_mono_log.h | 2 +- modules/mono/mono_gd/gd_mono_utils.cpp | 2 +- modules/mono/utils/mono_reg_utils.cpp | 2 +- modules/mono/utils/path_utils.cpp | 4 +- modules/mono/utils/string_utils.cpp | 2 +- modules/pvr/texture_loader_pvr.cpp | 2 +- modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 2 +- .../stb_vorbis/resource_importer_ogg_vorbis.cpp | 2 +- modules/theora/video_stream_theora.h | 2 +- modules/webm/video_stream_webm.cpp | 2 +- platform/android/dir_access_jandroid.h | 2 +- platform/android/export/export.cpp | 4 +- platform/android/export/gradle_export_util.h | 4 +- platform/android/file_access_android.h | 2 +- platform/iphone/export/export.cpp | 2 +- platform/iphone/os_iphone.mm | 4 +- .../api/javascript_tools_editor_plugin.cpp | 4 +- platform/linuxbsd/export/export.cpp | 2 +- platform/linuxbsd/os_linuxbsd.cpp | 2 +- platform/osx/dir_access_osx.h | 2 +- platform/osx/export/export.cpp | 4 +- platform/uwp/app.cpp | 4 +- platform/uwp/export/export.cpp | 4 +- platform/windows/export/export.cpp | 2 +- scene/3d/lightmap_gi.cpp | 4 +- scene/gui/file_dialog.h | 2 +- scene/main/http_request.h | 2 +- scene/main/scene_tree.cpp | 2 +- scene/resources/audio_stream_sample.cpp | 2 +- scene/resources/resource_format_text.cpp | 4 +- scene/resources/resource_format_text.h | 2 +- scene/resources/shader.cpp | 2 +- scene/resources/text_file.cpp | 2 +- scene/resources/texture.h | 2 +- scene/resources/theme.cpp | 2 +- servers/audio/effects/audio_effect_record.h | 2 +- servers/audio_server.cpp | 2 +- .../renderer_rd/renderer_compositor_rd.cpp | 2 +- servers/rendering/renderer_rd/shader_rd.cpp | 4 +- tests/test_file_access.h | 2 +- tests/test_math.cpp | 2 +- tests/test_shader_lang.cpp | 2 +- 164 files changed, 1621 insertions(+), 1621 deletions(-) create mode 100644 core/io/dir_access.cpp create mode 100644 core/io/dir_access.h create mode 100644 core/io/file_access.cpp create mode 100644 core/io/file_access.h delete mode 100644 core/os/dir_access.cpp delete mode 100644 core/os/dir_access.h delete mode 100644 core/os/file_access.cpp delete mode 100644 core/os/file_access.h diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 9baec79d43..a1782f4ef3 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -33,11 +33,11 @@ #include "core/core_bind.h" #include "core/core_string_names.h" #include "core/input/input_map.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/file_access_network.h" #include "core/io/file_access_pack.h" #include "core/io/marshalls.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/variant/variant_parser.h" diff --git a/core/core_bind.h b/core/core_bind.h index c8b0a4d7da..2de77a60c8 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -32,11 +32,11 @@ #define CORE_BIND_H #include "core/io/compression.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/image.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/os/semaphore.h" #include "core/os/thread.h" diff --git a/core/io/config_file.h b/core/io/config_file.h index 1b28257c60..3b2321b15a 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -31,8 +31,8 @@ #ifndef CONFIG_FILE_H #define CONFIG_FILE_H +#include "core/io/file_access.h" #include "core/object/reference.h" -#include "core/os/file_access.h" #include "core/templates/ordered_hash_map.h" #include "core/variant/variant_parser.h" diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp new file mode 100644 index 0000000000..dfba00067f --- /dev/null +++ b/core/io/dir_access.cpp @@ -0,0 +1,418 @@ +/*************************************************************************/ +/* dir_access.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "dir_access.h" + +#include "core/config/project_settings.h" +#include "core/io/file_access.h" +#include "core/os/memory.h" +#include "core/os/os.h" + +String DirAccess::_get_root_path() const { + switch (_access_type) { + case ACCESS_RESOURCES: + return ProjectSettings::get_singleton()->get_resource_path(); + case ACCESS_USERDATA: + return OS::get_singleton()->get_user_data_dir(); + default: + return ""; + } +} + +String DirAccess::_get_root_string() const { + switch (_access_type) { + case ACCESS_RESOURCES: + return "res://"; + case ACCESS_USERDATA: + return "user://"; + default: + return ""; + } +} + +int DirAccess::get_current_drive() { + String path = get_current_dir().to_lower(); + for (int i = 0; i < get_drive_count(); i++) { + String d = get_drive(i).to_lower(); + if (path.begins_with(d)) { + return i; + } + } + + return 0; +} + +bool DirAccess::drives_are_shortcuts() { + return false; +} + +static Error _erase_recursive(DirAccess *da) { + List dirs; + List files; + + da->list_dir_begin(); + String n = da->get_next(); + while (n != String()) { + if (n != "." && n != "..") { + if (da->current_is_dir()) { + dirs.push_back(n); + } else { + files.push_back(n); + } + } + + n = da->get_next(); + } + + da->list_dir_end(); + + for (List::Element *E = dirs.front(); E; E = E->next()) { + Error err = da->change_dir(E->get()); + if (err == OK) { + err = _erase_recursive(da); + if (err) { + da->change_dir(".."); + return err; + } + err = da->change_dir(".."); + if (err) { + return err; + } + err = da->remove(da->get_current_dir().plus_file(E->get())); + if (err) { + return err; + } + } else { + return err; + } + } + + for (List::Element *E = files.front(); E; E = E->next()) { + Error err = da->remove(da->get_current_dir().plus_file(E->get())); + if (err) { + return err; + } + } + + return OK; +} + +Error DirAccess::erase_contents_recursive() { + return _erase_recursive(this); +} + +Error DirAccess::make_dir_recursive(String p_dir) { + if (p_dir.length() < 1) { + return OK; + } + + String full_dir; + + if (p_dir.is_rel_path()) { + //append current + full_dir = get_current_dir().plus_file(p_dir); + + } else { + full_dir = p_dir; + } + + full_dir = full_dir.replace("\\", "/"); + + //int slices = full_dir.get_slice_count("/"); + + String base; + + if (full_dir.begins_with("res://")) { + base = "res://"; + } else if (full_dir.begins_with("user://")) { + base = "user://"; + } else if (full_dir.begins_with("/")) { + base = "/"; + } else if (full_dir.find(":/") != -1) { + base = full_dir.substr(0, full_dir.find(":/") + 2); + } else { + ERR_FAIL_V(ERR_INVALID_PARAMETER); + } + + full_dir = full_dir.replace_first(base, "").simplify_path(); + + Vector subdirs = full_dir.split("/"); + + String curpath = base; + for (int i = 0; i < subdirs.size(); i++) { + curpath = curpath.plus_file(subdirs[i]); + Error err = make_dir(curpath); + if (err != OK && err != ERR_ALREADY_EXISTS) { + ERR_FAIL_V_MSG(err, "Could not create directory: " + curpath); + } + } + + return OK; +} + +String DirAccess::fix_path(String p_path) const { + switch (_access_type) { + case ACCESS_RESOURCES: { + if (ProjectSettings::get_singleton()) { + if (p_path.begins_with("res://")) { + String resource_path = ProjectSettings::get_singleton()->get_resource_path(); + if (resource_path != "") { + return p_path.replace_first("res:/", resource_path); + } + return p_path.replace_first("res://", ""); + } + } + + } break; + case ACCESS_USERDATA: { + if (p_path.begins_with("user://")) { + String data_dir = OS::get_singleton()->get_user_data_dir(); + if (data_dir != "") { + return p_path.replace_first("user:/", data_dir); + } + return p_path.replace_first("user://", ""); + } + + } break; + case ACCESS_FILESYSTEM: { + return p_path; + } break; + case ACCESS_MAX: + break; // Can't happen, but silences warning + } + + return p_path; +} + +DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { nullptr, nullptr, nullptr }; + +DirAccess *DirAccess::create_for_path(const String &p_path) { + DirAccess *da = nullptr; + if (p_path.begins_with("res://")) { + da = create(ACCESS_RESOURCES); + } else if (p_path.begins_with("user://")) { + da = create(ACCESS_USERDATA); + } else { + da = create(ACCESS_FILESYSTEM); + } + + return da; +} + +DirAccess *DirAccess::open(const String &p_path, Error *r_error) { + DirAccess *da = create_for_path(p_path); + + ERR_FAIL_COND_V_MSG(!da, nullptr, "Cannot create DirAccess for path '" + p_path + "'."); + Error err = da->change_dir(p_path); + if (r_error) { + *r_error = err; + } + if (err != OK) { + memdelete(da); + return nullptr; + } + + return da; +} + +DirAccess *DirAccess::create(AccessType p_access) { + DirAccess *da = create_func[p_access] ? create_func[p_access]() : nullptr; + if (da) { + da->_access_type = p_access; + } + + return da; +} + +String DirAccess::get_full_path(const String &p_path, AccessType p_access) { + DirAccess *d = DirAccess::create(p_access); + if (!d) { + return p_path; + } + + d->change_dir(p_path); + String full = d->get_current_dir(); + memdelete(d); + return full; +} + +Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) { + //printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data()); + Error err; + FileAccess *fsrc = FileAccess::open(p_from, FileAccess::READ, &err); + + if (err) { + ERR_PRINT("Failed to open " + p_from); + return err; + } + + FileAccess *fdst = FileAccess::open(p_to, FileAccess::WRITE, &err); + if (err) { + fsrc->close(); + memdelete(fsrc); + ERR_PRINT("Failed to open " + p_to); + return err; + } + + fsrc->seek_end(0); + int size = fsrc->get_position(); + fsrc->seek(0); + err = OK; + while (size--) { + if (fsrc->get_error() != OK) { + err = fsrc->get_error(); + break; + } + if (fdst->get_error() != OK) { + err = fdst->get_error(); + break; + } + + fdst->store_8(fsrc->get_8()); + } + + if (err == OK && p_chmod_flags != -1) { + fdst->close(); + err = FileAccess::set_unix_permissions(p_to, p_chmod_flags); + // If running on a platform with no chmod support (i.e., Windows), don't fail + if (err == ERR_UNAVAILABLE) { + err = OK; + } + } + + memdelete(fsrc); + memdelete(fdst); + + return err; +} + +// Changes dir for the current scope, returning back to the original dir +// when scope exits +class DirChanger { + DirAccess *da; + String original_dir; + +public: + DirChanger(DirAccess *p_da, String p_dir) : + da(p_da), + original_dir(p_da->get_current_dir()) { + p_da->change_dir(p_dir); + } + + ~DirChanger() { + da->change_dir(original_dir); + } +}; + +Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags, bool p_copy_links) { + List dirs; + + String curdir = get_current_dir(); + list_dir_begin(); + String n = get_next(); + while (n != String()) { + if (n != "." && n != "..") { + if (p_copy_links && is_link(get_current_dir().plus_file(n))) { + create_link(read_link(get_current_dir().plus_file(n)), p_to + n); + } else if (current_is_dir()) { + dirs.push_back(n); + } else { + const String &rel_path = n; + if (!n.is_rel_path()) { + list_dir_end(); + return ERR_BUG; + } + Error err = copy(get_current_dir().plus_file(n), p_to + rel_path, p_chmod_flags); + if (err) { + list_dir_end(); + return err; + } + } + } + + n = get_next(); + } + + list_dir_end(); + + for (List::Element *E = dirs.front(); E; E = E->next()) { + String rel_path = E->get(); + String target_dir = p_to + rel_path; + if (!p_target_da->dir_exists(target_dir)) { + Error err = p_target_da->make_dir(target_dir); + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'."); + } + + Error err = change_dir(E->get()); + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'."); + + err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links); + if (err) { + change_dir(".."); + ERR_FAIL_V_MSG(err, "Failed to copy recursively."); + } + err = change_dir(".."); + ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to go back."); + } + + return OK; +} + +Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_copy_links) { + ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist."); + + DirAccess *target_da = DirAccess::create_for_path(p_to); + ERR_FAIL_COND_V_MSG(!target_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_to + "'."); + + if (!target_da->dir_exists(p_to)) { + Error err = target_da->make_dir_recursive(p_to); + if (err) { + memdelete(target_da); + } + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + p_to + "'."); + } + + if (!p_to.ends_with("/")) { + p_to = p_to + "/"; + } + + DirChanger dir_changer(this, p_from); + Error err = _copy_dir(target_da, p_to, p_chmod_flags, p_copy_links); + memdelete(target_da); + + return err; +} + +bool DirAccess::exists(String p_dir) { + DirAccess *da = DirAccess::create_for_path(p_dir); + bool valid = da->change_dir(p_dir) == OK; + memdelete(da); + return valid; +} diff --git a/core/io/dir_access.h b/core/io/dir_access.h new file mode 100644 index 0000000000..16154a4850 --- /dev/null +++ b/core/io/dir_access.h @@ -0,0 +1,147 @@ +/*************************************************************************/ +/* dir_access.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef DIR_ACCESS_H +#define DIR_ACCESS_H + +#include "core/string/ustring.h" +#include "core/typedefs.h" + +//@ TODO, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies +class DirAccess { +public: + enum AccessType { + ACCESS_RESOURCES, + ACCESS_USERDATA, + ACCESS_FILESYSTEM, + ACCESS_MAX + }; + + typedef DirAccess *(*CreateFunc)(); + +private: + AccessType _access_type = ACCESS_FILESYSTEM; + static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object + + Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags, bool p_copy_links); + +protected: + String _get_root_path() const; + String _get_root_string() const; + + String fix_path(String p_path) const; + + template + static DirAccess *_create_builtin() { + return memnew(T); + } + +public: + virtual Error list_dir_begin() = 0; ///< This starts dir listing + virtual String get_next() = 0; + virtual bool current_is_dir() const = 0; + virtual bool current_is_hidden() const = 0; + + virtual void list_dir_end() = 0; ///< + + virtual int get_drive_count() = 0; + virtual String get_drive(int p_drive) = 0; + virtual int get_current_drive(); + virtual bool drives_are_shortcuts(); + + virtual Error change_dir(String p_dir) = 0; ///< can be relative or absolute, return false on success + virtual String get_current_dir(bool p_include_drive = true) = 0; ///< return current dir location + virtual Error make_dir(String p_dir) = 0; + virtual Error make_dir_recursive(String p_dir); + virtual Error erase_contents_recursive(); //super dangerous, use with care! + + virtual bool file_exists(String p_file) = 0; + virtual bool dir_exists(String p_dir) = 0; + virtual bool is_readable(String p_dir) { return true; }; + virtual bool is_writable(String p_dir) { return true; }; + static bool exists(String p_dir); + virtual uint64_t get_space_left() = 0; + + Error copy_dir(String p_from, String p_to, int p_chmod_flags = -1, bool p_copy_links = false); + virtual Error copy(String p_from, String p_to, int p_chmod_flags = -1); + virtual Error rename(String p_from, String p_to) = 0; + virtual Error remove(String p_name) = 0; + + virtual bool is_link(String p_file) = 0; + virtual String read_link(String p_file) = 0; + virtual Error create_link(String p_source, String p_target) = 0; + + // Meant for editor code when we want to quickly remove a file without custom + // handling (e.g. removing a cache file). + static void remove_file_or_error(String p_path) { + DirAccess *da = create(ACCESS_FILESYSTEM); + if (da->file_exists(p_path)) { + if (da->remove(p_path) != OK) { + ERR_FAIL_MSG("Cannot remove file or directory: " + p_path); + } + } + memdelete(da); + } + + virtual String get_filesystem_type() const = 0; + static String get_full_path(const String &p_path, AccessType p_access); + static DirAccess *create_for_path(const String &p_path); + + static DirAccess *create(AccessType p_access); + + template + static void make_default(AccessType p_access) { + create_func[p_access] = _create_builtin; + } + + static DirAccess *open(const String &p_path, Error *r_error = nullptr); + + DirAccess() {} + virtual ~DirAccess() {} +}; + +struct DirAccessRef { + _FORCE_INLINE_ DirAccess *operator->() { + return f; + } + + operator bool() const { return f != nullptr; } + + DirAccess *f; + + DirAccessRef(DirAccess *fa) { f = fa; } + ~DirAccessRef() { + if (f) { + memdelete(f); + } + } +}; + +#endif // DIR_ACCESS_H diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp index 288b2efe0e..655fb18535 100644 --- a/core/io/dtls_server.cpp +++ b/core/io/dtls_server.cpp @@ -31,7 +31,7 @@ #include "dtls_server.h" #include "core/config/project_settings.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" DTLSServer *(*DTLSServer::_create)() = nullptr; bool DTLSServer::available = false; diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp new file mode 100644 index 0000000000..d21c0bd9a2 --- /dev/null +++ b/core/io/file_access.cpp @@ -0,0 +1,676 @@ +/*************************************************************************/ +/* file_access.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "file_access.h" + +#include "core/config/project_settings.h" +#include "core/crypto/crypto_core.h" +#include "core/io/file_access_pack.h" +#include "core/io/marshalls.h" +#include "core/os/os.h" + +FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX] = { nullptr, nullptr }; + +FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = nullptr; + +bool FileAccess::backup_save = false; + +FileAccess *FileAccess::create(AccessType p_access) { + ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr); + + FileAccess *ret = create_func[p_access](); + ret->_set_access_type(p_access); + return ret; +} + +bool FileAccess::exists(const String &p_name) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_name)) { + return true; + } + + FileAccess *f = open(p_name, READ); + if (!f) { + return false; + } + memdelete(f); + return true; +} + +void FileAccess::_set_access_type(AccessType p_access) { + _access_type = p_access; +} + +FileAccess *FileAccess::create_for_path(const String &p_path) { + FileAccess *ret = nullptr; + if (p_path.begins_with("res://")) { + ret = create(ACCESS_RESOURCES); + } else if (p_path.begins_with("user://")) { + ret = create(ACCESS_USERDATA); + + } else { + ret = create(ACCESS_FILESYSTEM); + } + + return ret; +} + +Error FileAccess::reopen(const String &p_path, int p_mode_flags) { + return _open(p_path, p_mode_flags); +} + +FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_error) { + //try packed data first + + FileAccess *ret = nullptr; + if (!(p_mode_flags & WRITE) && PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled()) { + ret = PackedData::get_singleton()->try_open_path(p_path); + if (ret) { + if (r_error) { + *r_error = OK; + } + return ret; + } + } + + ret = create_for_path(p_path); + Error err = ret->_open(p_path, p_mode_flags); + + if (r_error) { + *r_error = err; + } + if (err != OK) { + memdelete(ret); + ret = nullptr; + } + + return ret; +} + +FileAccess::CreateFunc FileAccess::get_create_func(AccessType p_access) { + return create_func[p_access]; +} + +String FileAccess::fix_path(const String &p_path) const { + //helper used by file accesses that use a single filesystem + + String r_path = p_path.replace("\\", "/"); + + switch (_access_type) { + case ACCESS_RESOURCES: { + if (ProjectSettings::get_singleton()) { + if (r_path.begins_with("res://")) { + String resource_path = ProjectSettings::get_singleton()->get_resource_path(); + if (resource_path != "") { + return r_path.replace("res:/", resource_path); + } + return r_path.replace("res://", ""); + } + } + + } break; + case ACCESS_USERDATA: { + if (r_path.begins_with("user://")) { + String data_dir = OS::get_singleton()->get_user_data_dir(); + if (data_dir != "") { + return r_path.replace("user:/", data_dir); + } + return r_path.replace("user://", ""); + } + + } break; + case ACCESS_FILESYSTEM: { + return r_path; + } break; + case ACCESS_MAX: + break; // Can't happen, but silences warning + } + + return r_path; +} + +/* these are all implemented for ease of porting, then can later be optimized */ + +uint16_t FileAccess::get_16() const { + uint16_t res; + uint8_t a, b; + + a = get_8(); + b = get_8(); + + if (big_endian) { + SWAP(a, b); + } + + res = b; + res <<= 8; + res |= a; + + return res; +} + +uint32_t FileAccess::get_32() const { + uint32_t res; + uint16_t a, b; + + a = get_16(); + b = get_16(); + + if (big_endian) { + SWAP(a, b); + } + + res = b; + res <<= 16; + res |= a; + + return res; +} + +uint64_t FileAccess::get_64() const { + uint64_t res; + uint32_t a, b; + + a = get_32(); + b = get_32(); + + if (big_endian) { + SWAP(a, b); + } + + res = b; + res <<= 32; + res |= a; + + return res; +} + +float FileAccess::get_float() const { + MarshallFloat m; + m.i = get_32(); + return m.f; +} + +real_t FileAccess::get_real() const { + if (real_is_double) { + return get_double(); + } else { + return get_float(); + } +} + +double FileAccess::get_double() const { + MarshallDouble m; + m.l = get_64(); + return m.d; +} + +String FileAccess::get_token() const { + CharString token; + + char32_t c = get_8(); + + while (!eof_reached()) { + if (c <= ' ') { + if (token.length()) { + break; + } + } else { + token += c; + } + c = get_8(); + } + + return String::utf8(token.get_data()); +} + +class CharBuffer { + Vector vector; + char stack_buffer[256]; + + char *buffer = nullptr; + int capacity = 0; + int written = 0; + + bool grow() { + if (vector.resize(next_power_of_2(1 + written)) != OK) { + return false; + } + + if (buffer == stack_buffer) { // first chunk? + + for (int i = 0; i < written; i++) { + vector.write[i] = stack_buffer[i]; + } + } + + buffer = vector.ptrw(); + capacity = vector.size(); + ERR_FAIL_COND_V(written >= capacity, false); + + return true; + } + +public: + _FORCE_INLINE_ CharBuffer() : + buffer(stack_buffer), + capacity(sizeof(stack_buffer) / sizeof(char)) { + } + + _FORCE_INLINE_ void push_back(char c) { + if (written >= capacity) { + ERR_FAIL_COND(!grow()); + } + + buffer[written++] = c; + } + + _FORCE_INLINE_ const char *get_data() const { + return buffer; + } +}; + +String FileAccess::get_line() const { + CharBuffer line; + + char32_t c = get_8(); + + while (!eof_reached()) { + if (c == '\n' || c == '\0') { + line.push_back(0); + return String::utf8(line.get_data()); + } else if (c != '\r') { + line.push_back(c); + } + + c = get_8(); + } + line.push_back(0); + return String::utf8(line.get_data()); +} + +Vector FileAccess::get_csv_line(const String &p_delim) const { + ERR_FAIL_COND_V(p_delim.length() != 1, Vector()); + + String l; + int qc = 0; + do { + if (eof_reached()) { + break; + } + + l += get_line() + "\n"; + qc = 0; + for (int i = 0; i < l.length(); i++) { + if (l[i] == '"') { + qc++; + } + } + + } while (qc % 2); + + l = l.substr(0, l.length() - 1); + + Vector strings; + + bool in_quote = false; + String current; + for (int i = 0; i < l.length(); i++) { + char32_t c = l[i]; + char32_t s[2] = { 0, 0 }; + + if (!in_quote && c == p_delim[0]) { + strings.push_back(current); + current = String(); + } else if (c == '"') { + if (l[i + 1] == '"' && in_quote) { + s[0] = '"'; + current += s; + i++; + } else { + in_quote = !in_quote; + } + } else { + s[0] = c; + current += s; + } + } + + strings.push_back(current); + + return strings; +} + +uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const { + ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); + + uint64_t i = 0; + for (i = 0; i < p_length && !eof_reached(); i++) { + p_dst[i] = get_8(); + } + + return i; +} + +String FileAccess::get_as_utf8_string() const { + Vector sourcef; + uint64_t len = get_length(); + sourcef.resize(len + 1); + + uint8_t *w = sourcef.ptrw(); + uint64_t r = get_buffer(w, len); + ERR_FAIL_COND_V(r != len, String()); + w[len] = 0; + + String s; + if (s.parse_utf8((const char *)w)) { + return String(); + } + return s; +} + +void FileAccess::store_16(uint16_t p_dest) { + uint8_t a, b; + + a = p_dest & 0xFF; + b = p_dest >> 8; + + if (big_endian) { + SWAP(a, b); + } + + store_8(a); + store_8(b); +} + +void FileAccess::store_32(uint32_t p_dest) { + uint16_t a, b; + + a = p_dest & 0xFFFF; + b = p_dest >> 16; + + if (big_endian) { + SWAP(a, b); + } + + store_16(a); + store_16(b); +} + +void FileAccess::store_64(uint64_t p_dest) { + uint32_t a, b; + + a = p_dest & 0xFFFFFFFF; + b = p_dest >> 32; + + if (big_endian) { + SWAP(a, b); + } + + store_32(a); + store_32(b); +} + +void FileAccess::store_real(real_t p_real) { + if (sizeof(real_t) == 4) { + store_float(p_real); + } else { + store_double(p_real); + } +} + +void FileAccess::store_float(float p_dest) { + MarshallFloat m; + m.f = p_dest; + store_32(m.i); +} + +void FileAccess::store_double(double p_dest) { + MarshallDouble m; + m.d = p_dest; + store_64(m.l); +} + +uint64_t FileAccess::get_modified_time(const String &p_file) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { + return 0; + } + + FileAccess *fa = create_for_path(p_file); + ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'."); + + uint64_t mt = fa->_get_modified_time(p_file); + memdelete(fa); + return mt; +} + +uint32_t FileAccess::get_unix_permissions(const String &p_file) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { + return 0; + } + + FileAccess *fa = create_for_path(p_file); + ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'."); + + uint32_t mt = fa->_get_unix_permissions(p_file); + memdelete(fa); + return mt; +} + +Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { + return ERR_UNAVAILABLE; + } + + FileAccess *fa = create_for_path(p_file); + ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'."); + + Error err = fa->_set_unix_permissions(p_file, p_permissions); + memdelete(fa); + return err; +} + +void FileAccess::store_string(const String &p_string) { + if (p_string.length() == 0) { + return; + } + + CharString cs = p_string.utf8(); + store_buffer((uint8_t *)&cs[0], cs.length()); +} + +void FileAccess::store_pascal_string(const String &p_string) { + CharString cs = p_string.utf8(); + store_32(cs.length()); + store_buffer((uint8_t *)&cs[0], cs.length()); +} + +String FileAccess::get_pascal_string() { + uint32_t sl = get_32(); + CharString cs; + cs.resize(sl + 1); + get_buffer((uint8_t *)cs.ptr(), sl); + cs[sl] = 0; + + String ret; + ret.parse_utf8(cs.ptr()); + + return ret; +} + +void FileAccess::store_line(const String &p_line) { + store_string(p_line); + store_8('\n'); +} + +void FileAccess::store_csv_line(const Vector &p_values, const String &p_delim) { + ERR_FAIL_COND(p_delim.length() != 1); + + String line = ""; + int size = p_values.size(); + for (int i = 0; i < size; ++i) { + String value = p_values[i]; + + if (value.find("\"") != -1 || value.find(p_delim) != -1 || value.find("\n") != -1) { + value = "\"" + value.replace("\"", "\"\"") + "\""; + } + if (i < size - 1) { + value += p_delim; + } + + line += value; + } + + store_line(line); +} + +void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) { + ERR_FAIL_COND(!p_src && p_length > 0); + for (uint64_t i = 0; i < p_length; i++) { + store_8(p_src[i]); + } +} + +Vector FileAccess::get_file_as_array(const String &p_path, Error *r_error) { + FileAccess *f = FileAccess::open(p_path, READ, r_error); + if (!f) { + if (r_error) { // if error requested, do not throw error + return Vector(); + } + ERR_FAIL_V_MSG(Vector(), "Can't open file from path '" + String(p_path) + "'."); + } + Vector data; + data.resize(f->get_length()); + f->get_buffer(data.ptrw(), data.size()); + memdelete(f); + return data; +} + +String FileAccess::get_file_as_string(const String &p_path, Error *r_error) { + Error err; + Vector array = get_file_as_array(p_path, &err); + if (r_error) { + *r_error = err; + } + if (err != OK) { + if (r_error) { + return String(); + } + ERR_FAIL_V_MSG(String(), "Can't get file as string from path '" + String(p_path) + "'."); + } + + String ret; + ret.parse_utf8((const char *)array.ptr(), array.size()); + return ret; +} + +String FileAccess::get_md5(const String &p_file) { + FileAccess *f = FileAccess::open(p_file, READ); + if (!f) { + return String(); + } + + CryptoCore::MD5Context ctx; + ctx.start(); + + unsigned char step[32768]; + + while (true) { + uint64_t br = f->get_buffer(step, 32768); + if (br > 0) { + ctx.update(step, br); + } + if (br < 4096) { + break; + } + } + + unsigned char hash[16]; + ctx.finish(hash); + + memdelete(f); + + return String::md5(hash); +} + +String FileAccess::get_multiple_md5(const Vector &p_file) { + CryptoCore::MD5Context ctx; + ctx.start(); + + for (int i = 0; i < p_file.size(); i++) { + FileAccess *f = FileAccess::open(p_file[i], READ); + ERR_CONTINUE(!f); + + unsigned char step[32768]; + + while (true) { + uint64_t br = f->get_buffer(step, 32768); + if (br > 0) { + ctx.update(step, br); + } + if (br < 4096) { + break; + } + } + memdelete(f); + } + + unsigned char hash[16]; + ctx.finish(hash); + + return String::md5(hash); +} + +String FileAccess::get_sha256(const String &p_file) { + FileAccess *f = FileAccess::open(p_file, READ); + if (!f) { + return String(); + } + + CryptoCore::SHA256Context ctx; + ctx.start(); + + unsigned char step[32768]; + + while (true) { + uint64_t br = f->get_buffer(step, 32768); + if (br > 0) { + ctx.update(step, br); + } + if (br < 4096) { + break; + } + } + + unsigned char hash[32]; + ctx.finish(hash); + + memdelete(f); + return String::hex_encode_buffer(hash, 32); +} diff --git a/core/io/file_access.h b/core/io/file_access.h new file mode 100644 index 0000000000..5804aa2c47 --- /dev/null +++ b/core/io/file_access.h @@ -0,0 +1,198 @@ +/*************************************************************************/ +/* file_access.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef FILE_ACCESS_H +#define FILE_ACCESS_H + +#include "core/math/math_defs.h" +#include "core/os/memory.h" +#include "core/string/ustring.h" +#include "core/typedefs.h" + +/** + * Multi-Platform abstraction for accessing to files. + */ + +class FileAccess { +public: + enum AccessType { + ACCESS_RESOURCES, + ACCESS_USERDATA, + ACCESS_FILESYSTEM, + ACCESS_MAX + }; + + typedef void (*FileCloseFailNotify)(const String &); + + typedef FileAccess *(*CreateFunc)(); + bool big_endian = false; + bool real_is_double = false; + + virtual uint32_t _get_unix_permissions(const String &p_file) = 0; + virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) = 0; + +protected: + String fix_path(const String &p_path) const; + virtual Error _open(const String &p_path, int p_mode_flags) = 0; ///< open a file + virtual uint64_t _get_modified_time(const String &p_file) = 0; + + static FileCloseFailNotify close_fail_notify; + +private: + static bool backup_save; + + AccessType _access_type = ACCESS_FILESYSTEM; + static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */ + template + static FileAccess *_create_builtin() { + return memnew(T); + } + +public: + static void set_file_close_fail_notify_callback(FileCloseFailNotify p_cbk) { close_fail_notify = p_cbk; } + + virtual void _set_access_type(AccessType p_access); + + enum ModeFlags { + READ = 1, + WRITE = 2, + READ_WRITE = 3, + WRITE_READ = 7, + }; + + virtual void close() = 0; ///< close a file + virtual bool is_open() const = 0; ///< true when file is open + + virtual String get_path() const { return ""; } /// returns the path for the current open file + virtual String get_path_absolute() const { return ""; } /// returns the absolute path for the current open file + + virtual void seek(uint64_t p_position) = 0; ///< seek to a given position + virtual void seek_end(int64_t p_position = 0) = 0; ///< seek from the end of file with negative offset + virtual uint64_t get_position() const = 0; ///< get position in the file + virtual uint64_t get_length() const = 0; ///< get size of the file + + virtual bool eof_reached() const = 0; ///< reading passed EOF + + virtual uint8_t get_8() const = 0; ///< get a byte + virtual uint16_t get_16() const; ///< get 16 bits uint + virtual uint32_t get_32() const; ///< get 32 bits uint + virtual uint64_t get_64() const; ///< get 64 bits uint + + virtual float get_float() const; + virtual double get_double() const; + virtual real_t get_real() const; + + virtual uint64_t get_buffer(uint8_t *p_dst, uint64_t p_length) const; ///< get an array of bytes + virtual String get_line() const; + virtual String get_token() const; + virtual Vector get_csv_line(const String &p_delim = ",") const; + virtual String get_as_utf8_string() const; + + /** + * Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac) + * It's not about the current CPU type but file formats. + * This flag gets reset to `false` (little endian) on each open. + */ + virtual void set_big_endian(bool p_big_endian) { big_endian = p_big_endian; } + inline bool is_big_endian() const { return big_endian; } + + virtual Error get_error() const = 0; ///< get last error + + virtual void flush() = 0; + virtual void store_8(uint8_t p_dest) = 0; ///< store a byte + virtual void store_16(uint16_t p_dest); ///< store 16 bits uint + virtual void store_32(uint32_t p_dest); ///< store 32 bits uint + virtual void store_64(uint64_t p_dest); ///< store 64 bits uint + + virtual void store_float(float p_dest); + virtual void store_double(double p_dest); + virtual void store_real(real_t p_real); + + virtual void store_string(const String &p_string); + virtual void store_line(const String &p_line); + virtual void store_csv_line(const Vector &p_values, const String &p_delim = ","); + + virtual void store_pascal_string(const String &p_string); + virtual String get_pascal_string(); + + virtual void store_buffer(const uint8_t *p_src, uint64_t p_length); ///< store an array of bytes + + virtual bool file_exists(const String &p_name) = 0; ///< return true if a file exists + + virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType + + static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. + static FileAccess *create_for_path(const String &p_path); + static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files. + static CreateFunc get_create_func(AccessType p_access); + static bool exists(const String &p_name); ///< return true if a file exists + static uint64_t get_modified_time(const String &p_file); + static uint32_t get_unix_permissions(const String &p_file); + static Error set_unix_permissions(const String &p_file, uint32_t p_permissions); + + static void set_backup_save(bool p_enable) { backup_save = p_enable; }; + static bool is_backup_save_enabled() { return backup_save; }; + + static String get_md5(const String &p_file); + static String get_sha256(const String &p_file); + static String get_multiple_md5(const Vector &p_file); + + static Vector get_file_as_array(const String &p_path, Error *r_error = nullptr); + static String get_file_as_string(const String &p_path, Error *r_error = nullptr); + + template + static void make_default(AccessType p_access) { + create_func[p_access] = _create_builtin; + } + + FileAccess() {} + virtual ~FileAccess() {} +}; + +struct FileAccessRef { + _FORCE_INLINE_ FileAccess *operator->() { + return f; + } + + operator bool() const { return f != nullptr; } + + FileAccess *f; + + operator FileAccess *() { return f; } + + FileAccessRef(FileAccess *fa) { f = fa; } + ~FileAccessRef() { + if (f) { + memdelete(f); + } + } +}; + +#endif // FILE_ACCESS_H diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index 19e4f241dd..3389e020e3 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -32,7 +32,7 @@ #define FILE_ACCESS_COMPRESSED_H #include "core/io/compression.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" class FileAccessCompressed : public FileAccess { Compression::Mode cmode = Compression::MODE_ZSTD; diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 00f14099f9..decffae696 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -31,7 +31,7 @@ #ifndef FILE_ACCESS_ENCRYPTED_H #define FILE_ACCESS_ENCRYPTED_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" #define ENCRYPTED_HEADER_MAGIC 0x43454447 diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index d9be2a4a75..627fd2bf9c 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -31,7 +31,7 @@ #include "file_access_memory.h" #include "core/config/project_settings.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/templates/map.h" static Map> *files = nullptr; diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index 4157531d01..14135bd68c 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -31,7 +31,7 @@ #ifndef FILE_ACCESS_MEMORY_H #define FILE_ACCESS_MEMORY_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" class FileAccessMemory : public FileAccess { uint8_t *data = nullptr; diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 94b66c2480..1d9d761fbb 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -31,8 +31,8 @@ #ifndef FILE_ACCESS_NETWORK_H #define FILE_ACCESS_NETWORK_H +#include "core/io/file_access.h" #include "core/io/stream_peer_tcp.h" -#include "core/os/file_access.h" #include "core/os/semaphore.h" #include "core/os/thread.h" diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 7a83fc938f..2f0ee62723 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -31,8 +31,8 @@ #ifndef FILE_ACCESS_PACK_H #define FILE_ACCESS_PACK_H -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/string/print_string.h" #include "core/templates/list.h" #include "core/templates/map.h" diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index b8383fd865..b5c882e9ce 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -32,7 +32,7 @@ #include "file_access_zip.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" ZipArchive *ZipArchive::instance = nullptr; diff --git a/core/io/image_loader.h b/core/io/image_loader.h index a5d588e0b5..6d1b1e3646 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -31,9 +31,9 @@ #ifndef IMAGE_LOADER_H #define IMAGE_LOADER_H +#include "core/io/file_access.h" #include "core/io/image.h" #include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "core/string/ustring.h" #include "core/templates/list.h" diff --git a/core/io/logger.cpp b/core/io/logger.cpp index 8a07459a1d..304581b4ac 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -31,7 +31,7 @@ #include "logger.h" #include "core/config/project_settings.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/os.h" #include "core/string/print_string.h" diff --git a/core/io/logger.h b/core/io/logger.h index a12945911c..ccf68562d6 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -31,7 +31,7 @@ #ifndef LOGGER_H #define LOGGER_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/string/ustring.h" #include "core/templates/vector.h" diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp index bac98e20e7..a6d220622b 100644 --- a/core/io/packet_peer_dtls.cpp +++ b/core/io/packet_peer_dtls.cpp @@ -30,7 +30,7 @@ #include "packet_peer_dtls.h" #include "core/config/project_settings.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" PacketPeerDTLS *(*PacketPeerDTLS::_create)() = nullptr; bool PacketPeerDTLS::available = false; diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index cadb02b5dd..806a95398f 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -31,9 +31,9 @@ #include "pck_packer.h" #include "core/crypto/crypto_core.h" +#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" #include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION -#include "core/os/file_access.h" #include "core/version.h" static int _get_pad(int p_alignment, int p_n) { diff --git a/core/io/resource.cpp b/core/io/resource.cpp index d46e9edafa..b970e85c99 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -31,9 +31,9 @@ #include "resource.h" #include "core/core_string_names.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/object/script_language.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "scene/main/node.h" //only so casting works diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 385f15c0cf..f83ba30514 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -31,10 +31,10 @@ #include "resource_format_binary.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "core/io/file_access_compressed.h" #include "core/io/image.h" #include "core/io/marshalls.h" -#include "core/os/dir_access.h" #include "core/version.h" //#define print_bl(m_what) print_line(m_what) diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 3592bbdbc4..abc7403935 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -31,9 +31,9 @@ #ifndef RESOURCE_FORMAT_BINARY_H #define RESOURCE_FORMAT_BINARY_H +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" class ResourceLoaderBinary { bool translation_remapped = false; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index b48c48b1bc..9839a563fd 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -31,8 +31,8 @@ #include "resource_loader.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_importer.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/string/print_string.h" #include "core/string/translation.h" diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 7ebc7f34b3..f7ddea7266 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -30,9 +30,9 @@ #include "resource_saver.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/object/script_language.h" -#include "core/os/file_access.h" Ref ResourceSaver::saver[MAX_SAVERS]; diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 9adf912224..83d575cee8 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -30,7 +30,7 @@ #include "translation_loader_po.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/string/translation.h" #include "core/string/translation_po.h" diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index 36d33fcac3..c52820e60d 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -31,8 +31,8 @@ #ifndef TRANSLATION_LOADER_PO_H #define TRANSLATION_LOADER_PO_H +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "core/string/translation.h" class TranslationLoaderPO : public ResourceFormatLoader { diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index c323301eac..15722b611e 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -31,8 +31,8 @@ #ifndef XML_PARSER_H #define XML_PARSER_H +#include "core/io/file_access.h" #include "core/object/reference.h" -#include "core/os/file_access.h" #include "core/string/ustring.h" #include "core/templates/vector.h" diff --git a/core/io/zip_io.h b/core/io/zip_io.h index 52691c65e9..776473bfa1 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -31,7 +31,7 @@ #ifndef ZIP_IO_H #define ZIP_IO_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" // Not directly used in this header, but assumed available in downstream users // like platform/*/export/export.cpp. Could be fixed, but probably better to have diff --git a/core/math/delaunay_3d.h b/core/math/delaunay_3d.h index 25cc1125db..6f7209556e 100644 --- a/core/math/delaunay_3d.h +++ b/core/math/delaunay_3d.h @@ -31,10 +31,10 @@ #ifndef DELAUNAY_3D_H #define DELAUNAY_3D_H +#include "core/io/file_access.h" #include "core/math/aabb.h" #include "core/math/camera_matrix.h" #include "core/math/vector3.h" -#include "core/os/file_access.h" #include "core/string/print_string.h" #include "core/templates/local_vector.h" #include "core/templates/oa_hash_map.h" diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp deleted file mode 100644 index 39ae475c12..0000000000 --- a/core/os/dir_access.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/*************************************************************************/ -/* dir_access.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "dir_access.h" - -#include "core/config/project_settings.h" -#include "core/os/file_access.h" -#include "core/os/memory.h" -#include "core/os/os.h" - -String DirAccess::_get_root_path() const { - switch (_access_type) { - case ACCESS_RESOURCES: - return ProjectSettings::get_singleton()->get_resource_path(); - case ACCESS_USERDATA: - return OS::get_singleton()->get_user_data_dir(); - default: - return ""; - } -} - -String DirAccess::_get_root_string() const { - switch (_access_type) { - case ACCESS_RESOURCES: - return "res://"; - case ACCESS_USERDATA: - return "user://"; - default: - return ""; - } -} - -int DirAccess::get_current_drive() { - String path = get_current_dir().to_lower(); - for (int i = 0; i < get_drive_count(); i++) { - String d = get_drive(i).to_lower(); - if (path.begins_with(d)) { - return i; - } - } - - return 0; -} - -bool DirAccess::drives_are_shortcuts() { - return false; -} - -static Error _erase_recursive(DirAccess *da) { - List dirs; - List files; - - da->list_dir_begin(); - String n = da->get_next(); - while (n != String()) { - if (n != "." && n != "..") { - if (da->current_is_dir()) { - dirs.push_back(n); - } else { - files.push_back(n); - } - } - - n = da->get_next(); - } - - da->list_dir_end(); - - for (List::Element *E = dirs.front(); E; E = E->next()) { - Error err = da->change_dir(E->get()); - if (err == OK) { - err = _erase_recursive(da); - if (err) { - da->change_dir(".."); - return err; - } - err = da->change_dir(".."); - if (err) { - return err; - } - err = da->remove(da->get_current_dir().plus_file(E->get())); - if (err) { - return err; - } - } else { - return err; - } - } - - for (List::Element *E = files.front(); E; E = E->next()) { - Error err = da->remove(da->get_current_dir().plus_file(E->get())); - if (err) { - return err; - } - } - - return OK; -} - -Error DirAccess::erase_contents_recursive() { - return _erase_recursive(this); -} - -Error DirAccess::make_dir_recursive(String p_dir) { - if (p_dir.length() < 1) { - return OK; - } - - String full_dir; - - if (p_dir.is_rel_path()) { - //append current - full_dir = get_current_dir().plus_file(p_dir); - - } else { - full_dir = p_dir; - } - - full_dir = full_dir.replace("\\", "/"); - - //int slices = full_dir.get_slice_count("/"); - - String base; - - if (full_dir.begins_with("res://")) { - base = "res://"; - } else if (full_dir.begins_with("user://")) { - base = "user://"; - } else if (full_dir.begins_with("/")) { - base = "/"; - } else if (full_dir.find(":/") != -1) { - base = full_dir.substr(0, full_dir.find(":/") + 2); - } else { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - } - - full_dir = full_dir.replace_first(base, "").simplify_path(); - - Vector subdirs = full_dir.split("/"); - - String curpath = base; - for (int i = 0; i < subdirs.size(); i++) { - curpath = curpath.plus_file(subdirs[i]); - Error err = make_dir(curpath); - if (err != OK && err != ERR_ALREADY_EXISTS) { - ERR_FAIL_V_MSG(err, "Could not create directory: " + curpath); - } - } - - return OK; -} - -String DirAccess::fix_path(String p_path) const { - switch (_access_type) { - case ACCESS_RESOURCES: { - if (ProjectSettings::get_singleton()) { - if (p_path.begins_with("res://")) { - String resource_path = ProjectSettings::get_singleton()->get_resource_path(); - if (resource_path != "") { - return p_path.replace_first("res:/", resource_path); - } - return p_path.replace_first("res://", ""); - } - } - - } break; - case ACCESS_USERDATA: { - if (p_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_user_data_dir(); - if (data_dir != "") { - return p_path.replace_first("user:/", data_dir); - } - return p_path.replace_first("user://", ""); - } - - } break; - case ACCESS_FILESYSTEM: { - return p_path; - } break; - case ACCESS_MAX: - break; // Can't happen, but silences warning - } - - return p_path; -} - -DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { nullptr, nullptr, nullptr }; - -DirAccess *DirAccess::create_for_path(const String &p_path) { - DirAccess *da = nullptr; - if (p_path.begins_with("res://")) { - da = create(ACCESS_RESOURCES); - } else if (p_path.begins_with("user://")) { - da = create(ACCESS_USERDATA); - } else { - da = create(ACCESS_FILESYSTEM); - } - - return da; -} - -DirAccess *DirAccess::open(const String &p_path, Error *r_error) { - DirAccess *da = create_for_path(p_path); - - ERR_FAIL_COND_V_MSG(!da, nullptr, "Cannot create DirAccess for path '" + p_path + "'."); - Error err = da->change_dir(p_path); - if (r_error) { - *r_error = err; - } - if (err != OK) { - memdelete(da); - return nullptr; - } - - return da; -} - -DirAccess *DirAccess::create(AccessType p_access) { - DirAccess *da = create_func[p_access] ? create_func[p_access]() : nullptr; - if (da) { - da->_access_type = p_access; - } - - return da; -} - -String DirAccess::get_full_path(const String &p_path, AccessType p_access) { - DirAccess *d = DirAccess::create(p_access); - if (!d) { - return p_path; - } - - d->change_dir(p_path); - String full = d->get_current_dir(); - memdelete(d); - return full; -} - -Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) { - //printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data()); - Error err; - FileAccess *fsrc = FileAccess::open(p_from, FileAccess::READ, &err); - - if (err) { - ERR_PRINT("Failed to open " + p_from); - return err; - } - - FileAccess *fdst = FileAccess::open(p_to, FileAccess::WRITE, &err); - if (err) { - fsrc->close(); - memdelete(fsrc); - ERR_PRINT("Failed to open " + p_to); - return err; - } - - fsrc->seek_end(0); - int size = fsrc->get_position(); - fsrc->seek(0); - err = OK; - while (size--) { - if (fsrc->get_error() != OK) { - err = fsrc->get_error(); - break; - } - if (fdst->get_error() != OK) { - err = fdst->get_error(); - break; - } - - fdst->store_8(fsrc->get_8()); - } - - if (err == OK && p_chmod_flags != -1) { - fdst->close(); - err = FileAccess::set_unix_permissions(p_to, p_chmod_flags); - // If running on a platform with no chmod support (i.e., Windows), don't fail - if (err == ERR_UNAVAILABLE) { - err = OK; - } - } - - memdelete(fsrc); - memdelete(fdst); - - return err; -} - -// Changes dir for the current scope, returning back to the original dir -// when scope exits -class DirChanger { - DirAccess *da; - String original_dir; - -public: - DirChanger(DirAccess *p_da, String p_dir) : - da(p_da), - original_dir(p_da->get_current_dir()) { - p_da->change_dir(p_dir); - } - - ~DirChanger() { - da->change_dir(original_dir); - } -}; - -Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags, bool p_copy_links) { - List dirs; - - String curdir = get_current_dir(); - list_dir_begin(); - String n = get_next(); - while (n != String()) { - if (n != "." && n != "..") { - if (p_copy_links && is_link(get_current_dir().plus_file(n))) { - create_link(read_link(get_current_dir().plus_file(n)), p_to + n); - } else if (current_is_dir()) { - dirs.push_back(n); - } else { - const String &rel_path = n; - if (!n.is_rel_path()) { - list_dir_end(); - return ERR_BUG; - } - Error err = copy(get_current_dir().plus_file(n), p_to + rel_path, p_chmod_flags); - if (err) { - list_dir_end(); - return err; - } - } - } - - n = get_next(); - } - - list_dir_end(); - - for (List::Element *E = dirs.front(); E; E = E->next()) { - String rel_path = E->get(); - String target_dir = p_to + rel_path; - if (!p_target_da->dir_exists(target_dir)) { - Error err = p_target_da->make_dir(target_dir); - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'."); - } - - Error err = change_dir(E->get()); - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'."); - - err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links); - if (err) { - change_dir(".."); - ERR_FAIL_V_MSG(err, "Failed to copy recursively."); - } - err = change_dir(".."); - ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to go back."); - } - - return OK; -} - -Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_copy_links) { - ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist."); - - DirAccess *target_da = DirAccess::create_for_path(p_to); - ERR_FAIL_COND_V_MSG(!target_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_to + "'."); - - if (!target_da->dir_exists(p_to)) { - Error err = target_da->make_dir_recursive(p_to); - if (err) { - memdelete(target_da); - } - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + p_to + "'."); - } - - if (!p_to.ends_with("/")) { - p_to = p_to + "/"; - } - - DirChanger dir_changer(this, p_from); - Error err = _copy_dir(target_da, p_to, p_chmod_flags, p_copy_links); - memdelete(target_da); - - return err; -} - -bool DirAccess::exists(String p_dir) { - DirAccess *da = DirAccess::create_for_path(p_dir); - bool valid = da->change_dir(p_dir) == OK; - memdelete(da); - return valid; -} diff --git a/core/os/dir_access.h b/core/os/dir_access.h deleted file mode 100644 index 16154a4850..0000000000 --- a/core/os/dir_access.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************/ -/* dir_access.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef DIR_ACCESS_H -#define DIR_ACCESS_H - -#include "core/string/ustring.h" -#include "core/typedefs.h" - -//@ TODO, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies -class DirAccess { -public: - enum AccessType { - ACCESS_RESOURCES, - ACCESS_USERDATA, - ACCESS_FILESYSTEM, - ACCESS_MAX - }; - - typedef DirAccess *(*CreateFunc)(); - -private: - AccessType _access_type = ACCESS_FILESYSTEM; - static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object - - Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags, bool p_copy_links); - -protected: - String _get_root_path() const; - String _get_root_string() const; - - String fix_path(String p_path) const; - - template - static DirAccess *_create_builtin() { - return memnew(T); - } - -public: - virtual Error list_dir_begin() = 0; ///< This starts dir listing - virtual String get_next() = 0; - virtual bool current_is_dir() const = 0; - virtual bool current_is_hidden() const = 0; - - virtual void list_dir_end() = 0; ///< - - virtual int get_drive_count() = 0; - virtual String get_drive(int p_drive) = 0; - virtual int get_current_drive(); - virtual bool drives_are_shortcuts(); - - virtual Error change_dir(String p_dir) = 0; ///< can be relative or absolute, return false on success - virtual String get_current_dir(bool p_include_drive = true) = 0; ///< return current dir location - virtual Error make_dir(String p_dir) = 0; - virtual Error make_dir_recursive(String p_dir); - virtual Error erase_contents_recursive(); //super dangerous, use with care! - - virtual bool file_exists(String p_file) = 0; - virtual bool dir_exists(String p_dir) = 0; - virtual bool is_readable(String p_dir) { return true; }; - virtual bool is_writable(String p_dir) { return true; }; - static bool exists(String p_dir); - virtual uint64_t get_space_left() = 0; - - Error copy_dir(String p_from, String p_to, int p_chmod_flags = -1, bool p_copy_links = false); - virtual Error copy(String p_from, String p_to, int p_chmod_flags = -1); - virtual Error rename(String p_from, String p_to) = 0; - virtual Error remove(String p_name) = 0; - - virtual bool is_link(String p_file) = 0; - virtual String read_link(String p_file) = 0; - virtual Error create_link(String p_source, String p_target) = 0; - - // Meant for editor code when we want to quickly remove a file without custom - // handling (e.g. removing a cache file). - static void remove_file_or_error(String p_path) { - DirAccess *da = create(ACCESS_FILESYSTEM); - if (da->file_exists(p_path)) { - if (da->remove(p_path) != OK) { - ERR_FAIL_MSG("Cannot remove file or directory: " + p_path); - } - } - memdelete(da); - } - - virtual String get_filesystem_type() const = 0; - static String get_full_path(const String &p_path, AccessType p_access); - static DirAccess *create_for_path(const String &p_path); - - static DirAccess *create(AccessType p_access); - - template - static void make_default(AccessType p_access) { - create_func[p_access] = _create_builtin; - } - - static DirAccess *open(const String &p_path, Error *r_error = nullptr); - - DirAccess() {} - virtual ~DirAccess() {} -}; - -struct DirAccessRef { - _FORCE_INLINE_ DirAccess *operator->() { - return f; - } - - operator bool() const { return f != nullptr; } - - DirAccess *f; - - DirAccessRef(DirAccess *fa) { f = fa; } - ~DirAccessRef() { - if (f) { - memdelete(f); - } - } -}; - -#endif // DIR_ACCESS_H diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp deleted file mode 100644 index d21c0bd9a2..0000000000 --- a/core/os/file_access.cpp +++ /dev/null @@ -1,676 +0,0 @@ -/*************************************************************************/ -/* file_access.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "file_access.h" - -#include "core/config/project_settings.h" -#include "core/crypto/crypto_core.h" -#include "core/io/file_access_pack.h" -#include "core/io/marshalls.h" -#include "core/os/os.h" - -FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX] = { nullptr, nullptr }; - -FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = nullptr; - -bool FileAccess::backup_save = false; - -FileAccess *FileAccess::create(AccessType p_access) { - ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr); - - FileAccess *ret = create_func[p_access](); - ret->_set_access_type(p_access); - return ret; -} - -bool FileAccess::exists(const String &p_name) { - if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_name)) { - return true; - } - - FileAccess *f = open(p_name, READ); - if (!f) { - return false; - } - memdelete(f); - return true; -} - -void FileAccess::_set_access_type(AccessType p_access) { - _access_type = p_access; -} - -FileAccess *FileAccess::create_for_path(const String &p_path) { - FileAccess *ret = nullptr; - if (p_path.begins_with("res://")) { - ret = create(ACCESS_RESOURCES); - } else if (p_path.begins_with("user://")) { - ret = create(ACCESS_USERDATA); - - } else { - ret = create(ACCESS_FILESYSTEM); - } - - return ret; -} - -Error FileAccess::reopen(const String &p_path, int p_mode_flags) { - return _open(p_path, p_mode_flags); -} - -FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_error) { - //try packed data first - - FileAccess *ret = nullptr; - if (!(p_mode_flags & WRITE) && PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled()) { - ret = PackedData::get_singleton()->try_open_path(p_path); - if (ret) { - if (r_error) { - *r_error = OK; - } - return ret; - } - } - - ret = create_for_path(p_path); - Error err = ret->_open(p_path, p_mode_flags); - - if (r_error) { - *r_error = err; - } - if (err != OK) { - memdelete(ret); - ret = nullptr; - } - - return ret; -} - -FileAccess::CreateFunc FileAccess::get_create_func(AccessType p_access) { - return create_func[p_access]; -} - -String FileAccess::fix_path(const String &p_path) const { - //helper used by file accesses that use a single filesystem - - String r_path = p_path.replace("\\", "/"); - - switch (_access_type) { - case ACCESS_RESOURCES: { - if (ProjectSettings::get_singleton()) { - if (r_path.begins_with("res://")) { - String resource_path = ProjectSettings::get_singleton()->get_resource_path(); - if (resource_path != "") { - return r_path.replace("res:/", resource_path); - } - return r_path.replace("res://", ""); - } - } - - } break; - case ACCESS_USERDATA: { - if (r_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_user_data_dir(); - if (data_dir != "") { - return r_path.replace("user:/", data_dir); - } - return r_path.replace("user://", ""); - } - - } break; - case ACCESS_FILESYSTEM: { - return r_path; - } break; - case ACCESS_MAX: - break; // Can't happen, but silences warning - } - - return r_path; -} - -/* these are all implemented for ease of porting, then can later be optimized */ - -uint16_t FileAccess::get_16() const { - uint16_t res; - uint8_t a, b; - - a = get_8(); - b = get_8(); - - if (big_endian) { - SWAP(a, b); - } - - res = b; - res <<= 8; - res |= a; - - return res; -} - -uint32_t FileAccess::get_32() const { - uint32_t res; - uint16_t a, b; - - a = get_16(); - b = get_16(); - - if (big_endian) { - SWAP(a, b); - } - - res = b; - res <<= 16; - res |= a; - - return res; -} - -uint64_t FileAccess::get_64() const { - uint64_t res; - uint32_t a, b; - - a = get_32(); - b = get_32(); - - if (big_endian) { - SWAP(a, b); - } - - res = b; - res <<= 32; - res |= a; - - return res; -} - -float FileAccess::get_float() const { - MarshallFloat m; - m.i = get_32(); - return m.f; -} - -real_t FileAccess::get_real() const { - if (real_is_double) { - return get_double(); - } else { - return get_float(); - } -} - -double FileAccess::get_double() const { - MarshallDouble m; - m.l = get_64(); - return m.d; -} - -String FileAccess::get_token() const { - CharString token; - - char32_t c = get_8(); - - while (!eof_reached()) { - if (c <= ' ') { - if (token.length()) { - break; - } - } else { - token += c; - } - c = get_8(); - } - - return String::utf8(token.get_data()); -} - -class CharBuffer { - Vector vector; - char stack_buffer[256]; - - char *buffer = nullptr; - int capacity = 0; - int written = 0; - - bool grow() { - if (vector.resize(next_power_of_2(1 + written)) != OK) { - return false; - } - - if (buffer == stack_buffer) { // first chunk? - - for (int i = 0; i < written; i++) { - vector.write[i] = stack_buffer[i]; - } - } - - buffer = vector.ptrw(); - capacity = vector.size(); - ERR_FAIL_COND_V(written >= capacity, false); - - return true; - } - -public: - _FORCE_INLINE_ CharBuffer() : - buffer(stack_buffer), - capacity(sizeof(stack_buffer) / sizeof(char)) { - } - - _FORCE_INLINE_ void push_back(char c) { - if (written >= capacity) { - ERR_FAIL_COND(!grow()); - } - - buffer[written++] = c; - } - - _FORCE_INLINE_ const char *get_data() const { - return buffer; - } -}; - -String FileAccess::get_line() const { - CharBuffer line; - - char32_t c = get_8(); - - while (!eof_reached()) { - if (c == '\n' || c == '\0') { - line.push_back(0); - return String::utf8(line.get_data()); - } else if (c != '\r') { - line.push_back(c); - } - - c = get_8(); - } - line.push_back(0); - return String::utf8(line.get_data()); -} - -Vector FileAccess::get_csv_line(const String &p_delim) const { - ERR_FAIL_COND_V(p_delim.length() != 1, Vector()); - - String l; - int qc = 0; - do { - if (eof_reached()) { - break; - } - - l += get_line() + "\n"; - qc = 0; - for (int i = 0; i < l.length(); i++) { - if (l[i] == '"') { - qc++; - } - } - - } while (qc % 2); - - l = l.substr(0, l.length() - 1); - - Vector strings; - - bool in_quote = false; - String current; - for (int i = 0; i < l.length(); i++) { - char32_t c = l[i]; - char32_t s[2] = { 0, 0 }; - - if (!in_quote && c == p_delim[0]) { - strings.push_back(current); - current = String(); - } else if (c == '"') { - if (l[i + 1] == '"' && in_quote) { - s[0] = '"'; - current += s; - i++; - } else { - in_quote = !in_quote; - } - } else { - s[0] = c; - current += s; - } - } - - strings.push_back(current); - - return strings; -} - -uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const { - ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); - - uint64_t i = 0; - for (i = 0; i < p_length && !eof_reached(); i++) { - p_dst[i] = get_8(); - } - - return i; -} - -String FileAccess::get_as_utf8_string() const { - Vector sourcef; - uint64_t len = get_length(); - sourcef.resize(len + 1); - - uint8_t *w = sourcef.ptrw(); - uint64_t r = get_buffer(w, len); - ERR_FAIL_COND_V(r != len, String()); - w[len] = 0; - - String s; - if (s.parse_utf8((const char *)w)) { - return String(); - } - return s; -} - -void FileAccess::store_16(uint16_t p_dest) { - uint8_t a, b; - - a = p_dest & 0xFF; - b = p_dest >> 8; - - if (big_endian) { - SWAP(a, b); - } - - store_8(a); - store_8(b); -} - -void FileAccess::store_32(uint32_t p_dest) { - uint16_t a, b; - - a = p_dest & 0xFFFF; - b = p_dest >> 16; - - if (big_endian) { - SWAP(a, b); - } - - store_16(a); - store_16(b); -} - -void FileAccess::store_64(uint64_t p_dest) { - uint32_t a, b; - - a = p_dest & 0xFFFFFFFF; - b = p_dest >> 32; - - if (big_endian) { - SWAP(a, b); - } - - store_32(a); - store_32(b); -} - -void FileAccess::store_real(real_t p_real) { - if (sizeof(real_t) == 4) { - store_float(p_real); - } else { - store_double(p_real); - } -} - -void FileAccess::store_float(float p_dest) { - MarshallFloat m; - m.f = p_dest; - store_32(m.i); -} - -void FileAccess::store_double(double p_dest) { - MarshallDouble m; - m.d = p_dest; - store_64(m.l); -} - -uint64_t FileAccess::get_modified_time(const String &p_file) { - if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { - return 0; - } - - FileAccess *fa = create_for_path(p_file); - ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'."); - - uint64_t mt = fa->_get_modified_time(p_file); - memdelete(fa); - return mt; -} - -uint32_t FileAccess::get_unix_permissions(const String &p_file) { - if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { - return 0; - } - - FileAccess *fa = create_for_path(p_file); - ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'."); - - uint32_t mt = fa->_get_unix_permissions(p_file); - memdelete(fa); - return mt; -} - -Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) { - if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { - return ERR_UNAVAILABLE; - } - - FileAccess *fa = create_for_path(p_file); - ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'."); - - Error err = fa->_set_unix_permissions(p_file, p_permissions); - memdelete(fa); - return err; -} - -void FileAccess::store_string(const String &p_string) { - if (p_string.length() == 0) { - return; - } - - CharString cs = p_string.utf8(); - store_buffer((uint8_t *)&cs[0], cs.length()); -} - -void FileAccess::store_pascal_string(const String &p_string) { - CharString cs = p_string.utf8(); - store_32(cs.length()); - store_buffer((uint8_t *)&cs[0], cs.length()); -} - -String FileAccess::get_pascal_string() { - uint32_t sl = get_32(); - CharString cs; - cs.resize(sl + 1); - get_buffer((uint8_t *)cs.ptr(), sl); - cs[sl] = 0; - - String ret; - ret.parse_utf8(cs.ptr()); - - return ret; -} - -void FileAccess::store_line(const String &p_line) { - store_string(p_line); - store_8('\n'); -} - -void FileAccess::store_csv_line(const Vector &p_values, const String &p_delim) { - ERR_FAIL_COND(p_delim.length() != 1); - - String line = ""; - int size = p_values.size(); - for (int i = 0; i < size; ++i) { - String value = p_values[i]; - - if (value.find("\"") != -1 || value.find(p_delim) != -1 || value.find("\n") != -1) { - value = "\"" + value.replace("\"", "\"\"") + "\""; - } - if (i < size - 1) { - value += p_delim; - } - - line += value; - } - - store_line(line); -} - -void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) { - ERR_FAIL_COND(!p_src && p_length > 0); - for (uint64_t i = 0; i < p_length; i++) { - store_8(p_src[i]); - } -} - -Vector FileAccess::get_file_as_array(const String &p_path, Error *r_error) { - FileAccess *f = FileAccess::open(p_path, READ, r_error); - if (!f) { - if (r_error) { // if error requested, do not throw error - return Vector(); - } - ERR_FAIL_V_MSG(Vector(), "Can't open file from path '" + String(p_path) + "'."); - } - Vector data; - data.resize(f->get_length()); - f->get_buffer(data.ptrw(), data.size()); - memdelete(f); - return data; -} - -String FileAccess::get_file_as_string(const String &p_path, Error *r_error) { - Error err; - Vector array = get_file_as_array(p_path, &err); - if (r_error) { - *r_error = err; - } - if (err != OK) { - if (r_error) { - return String(); - } - ERR_FAIL_V_MSG(String(), "Can't get file as string from path '" + String(p_path) + "'."); - } - - String ret; - ret.parse_utf8((const char *)array.ptr(), array.size()); - return ret; -} - -String FileAccess::get_md5(const String &p_file) { - FileAccess *f = FileAccess::open(p_file, READ); - if (!f) { - return String(); - } - - CryptoCore::MD5Context ctx; - ctx.start(); - - unsigned char step[32768]; - - while (true) { - uint64_t br = f->get_buffer(step, 32768); - if (br > 0) { - ctx.update(step, br); - } - if (br < 4096) { - break; - } - } - - unsigned char hash[16]; - ctx.finish(hash); - - memdelete(f); - - return String::md5(hash); -} - -String FileAccess::get_multiple_md5(const Vector &p_file) { - CryptoCore::MD5Context ctx; - ctx.start(); - - for (int i = 0; i < p_file.size(); i++) { - FileAccess *f = FileAccess::open(p_file[i], READ); - ERR_CONTINUE(!f); - - unsigned char step[32768]; - - while (true) { - uint64_t br = f->get_buffer(step, 32768); - if (br > 0) { - ctx.update(step, br); - } - if (br < 4096) { - break; - } - } - memdelete(f); - } - - unsigned char hash[16]; - ctx.finish(hash); - - return String::md5(hash); -} - -String FileAccess::get_sha256(const String &p_file) { - FileAccess *f = FileAccess::open(p_file, READ); - if (!f) { - return String(); - } - - CryptoCore::SHA256Context ctx; - ctx.start(); - - unsigned char step[32768]; - - while (true) { - uint64_t br = f->get_buffer(step, 32768); - if (br > 0) { - ctx.update(step, br); - } - if (br < 4096) { - break; - } - } - - unsigned char hash[32]; - ctx.finish(hash); - - memdelete(f); - return String::hex_encode_buffer(hash, 32); -} diff --git a/core/os/file_access.h b/core/os/file_access.h deleted file mode 100644 index 5804aa2c47..0000000000 --- a/core/os/file_access.h +++ /dev/null @@ -1,198 +0,0 @@ -/*************************************************************************/ -/* file_access.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef FILE_ACCESS_H -#define FILE_ACCESS_H - -#include "core/math/math_defs.h" -#include "core/os/memory.h" -#include "core/string/ustring.h" -#include "core/typedefs.h" - -/** - * Multi-Platform abstraction for accessing to files. - */ - -class FileAccess { -public: - enum AccessType { - ACCESS_RESOURCES, - ACCESS_USERDATA, - ACCESS_FILESYSTEM, - ACCESS_MAX - }; - - typedef void (*FileCloseFailNotify)(const String &); - - typedef FileAccess *(*CreateFunc)(); - bool big_endian = false; - bool real_is_double = false; - - virtual uint32_t _get_unix_permissions(const String &p_file) = 0; - virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) = 0; - -protected: - String fix_path(const String &p_path) const; - virtual Error _open(const String &p_path, int p_mode_flags) = 0; ///< open a file - virtual uint64_t _get_modified_time(const String &p_file) = 0; - - static FileCloseFailNotify close_fail_notify; - -private: - static bool backup_save; - - AccessType _access_type = ACCESS_FILESYSTEM; - static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */ - template - static FileAccess *_create_builtin() { - return memnew(T); - } - -public: - static void set_file_close_fail_notify_callback(FileCloseFailNotify p_cbk) { close_fail_notify = p_cbk; } - - virtual void _set_access_type(AccessType p_access); - - enum ModeFlags { - READ = 1, - WRITE = 2, - READ_WRITE = 3, - WRITE_READ = 7, - }; - - virtual void close() = 0; ///< close a file - virtual bool is_open() const = 0; ///< true when file is open - - virtual String get_path() const { return ""; } /// returns the path for the current open file - virtual String get_path_absolute() const { return ""; } /// returns the absolute path for the current open file - - virtual void seek(uint64_t p_position) = 0; ///< seek to a given position - virtual void seek_end(int64_t p_position = 0) = 0; ///< seek from the end of file with negative offset - virtual uint64_t get_position() const = 0; ///< get position in the file - virtual uint64_t get_length() const = 0; ///< get size of the file - - virtual bool eof_reached() const = 0; ///< reading passed EOF - - virtual uint8_t get_8() const = 0; ///< get a byte - virtual uint16_t get_16() const; ///< get 16 bits uint - virtual uint32_t get_32() const; ///< get 32 bits uint - virtual uint64_t get_64() const; ///< get 64 bits uint - - virtual float get_float() const; - virtual double get_double() const; - virtual real_t get_real() const; - - virtual uint64_t get_buffer(uint8_t *p_dst, uint64_t p_length) const; ///< get an array of bytes - virtual String get_line() const; - virtual String get_token() const; - virtual Vector get_csv_line(const String &p_delim = ",") const; - virtual String get_as_utf8_string() const; - - /** - * Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac) - * It's not about the current CPU type but file formats. - * This flag gets reset to `false` (little endian) on each open. - */ - virtual void set_big_endian(bool p_big_endian) { big_endian = p_big_endian; } - inline bool is_big_endian() const { return big_endian; } - - virtual Error get_error() const = 0; ///< get last error - - virtual void flush() = 0; - virtual void store_8(uint8_t p_dest) = 0; ///< store a byte - virtual void store_16(uint16_t p_dest); ///< store 16 bits uint - virtual void store_32(uint32_t p_dest); ///< store 32 bits uint - virtual void store_64(uint64_t p_dest); ///< store 64 bits uint - - virtual void store_float(float p_dest); - virtual void store_double(double p_dest); - virtual void store_real(real_t p_real); - - virtual void store_string(const String &p_string); - virtual void store_line(const String &p_line); - virtual void store_csv_line(const Vector &p_values, const String &p_delim = ","); - - virtual void store_pascal_string(const String &p_string); - virtual String get_pascal_string(); - - virtual void store_buffer(const uint8_t *p_src, uint64_t p_length); ///< store an array of bytes - - virtual bool file_exists(const String &p_name) = 0; ///< return true if a file exists - - virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType - - static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. - static FileAccess *create_for_path(const String &p_path); - static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files. - static CreateFunc get_create_func(AccessType p_access); - static bool exists(const String &p_name); ///< return true if a file exists - static uint64_t get_modified_time(const String &p_file); - static uint32_t get_unix_permissions(const String &p_file); - static Error set_unix_permissions(const String &p_file, uint32_t p_permissions); - - static void set_backup_save(bool p_enable) { backup_save = p_enable; }; - static bool is_backup_save_enabled() { return backup_save; }; - - static String get_md5(const String &p_file); - static String get_sha256(const String &p_file); - static String get_multiple_md5(const Vector &p_file); - - static Vector get_file_as_array(const String &p_path, Error *r_error = nullptr); - static String get_file_as_string(const String &p_path, Error *r_error = nullptr); - - template - static void make_default(AccessType p_access) { - create_func[p_access] = _create_builtin; - } - - FileAccess() {} - virtual ~FileAccess() {} -}; - -struct FileAccessRef { - _FORCE_INLINE_ FileAccess *operator->() { - return f; - } - - operator bool() const { return f != nullptr; } - - FileAccess *f; - - operator FileAccess *() { return f; } - - FileAccessRef(FileAccess *fa) { f = fa; } - ~FileAccessRef() { - if (f) { - memdelete(f); - } - } -}; - -#endif // FILE_ACCESS_H diff --git a/core/os/os.cpp b/core/os/os.cpp index c5463cf216..e2eecae58e 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -32,8 +32,8 @@ #include "core/config/project_settings.h" #include "core/input/input.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/os/midi_driver.h" #include "core/version_generated.gen.h" #include "servers/audio_server.h" diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index ad768f7140..d6b84cabc9 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -30,7 +30,7 @@ #include "translation_po.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #ifdef DEBUG_TRANSLATION_PO void TranslationPO::print_translation_map() { diff --git a/core/variant/variant_parser.h b/core/variant/variant_parser.h index 5703f0200c..05fc29b5e0 100644 --- a/core/variant/variant_parser.h +++ b/core/variant/variant_parser.h @@ -31,8 +31,8 @@ #ifndef VARIANT_PARSER_H #define VARIANT_PARSER_H +#include "core/io/file_access.h" #include "core/io/resource.h" -#include "core/os/file_access.h" #include "core/variant/variant.h" class VariantParser { diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index b737a287d1..2971880985 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -30,8 +30,8 @@ #include "resource_saver_png.h" +#include "core/io/file_access.h" #include "core/io/image.h" -#include "core/os/file_access.h" #include "drivers/png/png_driver_common.h" #include "scene/resources/texture.h" diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index 28a7053d25..8b19308967 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -33,7 +33,7 @@ #if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED) -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include #include diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h index 5b1599c67f..8b27c308e1 100644 --- a/drivers/unix/file_access_unix.h +++ b/drivers/unix/file_access_unix.h @@ -31,7 +31,7 @@ #ifndef FILE_ACCESS_UNIX_H #define FILE_ACCESS_UNIX_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/memory.h" #include diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index dc92e04a43..4cb878eb4d 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -31,7 +31,7 @@ #include "rendering_device_vulkan.h" #include "core/config/project_settings.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #include "core/templates/hashfuncs.h" #include "drivers/vulkan/vulkan_context.h" diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h index b151b631e9..1ba4e70e42 100644 --- a/drivers/windows/dir_access_windows.h +++ b/drivers/windows/dir_access_windows.h @@ -33,7 +33,7 @@ #ifdef WINDOWS_ENABLED -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" /** @author Juan Linietsky diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index 95f3a75548..7280fc3237 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -33,7 +33,7 @@ #ifdef WINDOWS_ENABLED -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/memory.h" #include diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index c085205f63..7534b419fe 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -30,8 +30,8 @@ #include "dependency_editor.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "editor_node.h" #include "editor_scale.h" #include "scene/gui/margin_container.h" diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index e29c9593c3..d3df4d91a6 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -34,9 +34,9 @@ #include "core/config/project_settings.h" #include "core/core_constants.h" #include "core/io/compression.h" +#include "core/io/dir_access.h" #include "core/io/marshalls.h" #include "core/object/script_language.h" -#include "core/os/dir_access.h" #include "core/version.h" #include "scene/resources/theme.h" diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index e7937a8e3c..38f417a8ce 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -30,9 +30,9 @@ #include "editor_asset_installer.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/zip_io.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "editor_node.h" #include "progress_dialog.h" diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 6405af3876..5d1ec853c9 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -31,9 +31,9 @@ #include "editor_data.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "editor_node.h" #include "editor_settings.h" #include "scene/resources/packed_scene.h" diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index 05451b7bda..ef473b0779 100644 --- a/editor/editor_dir_dialog.h +++ b/editor/editor_dir_dialog.h @@ -31,7 +31,7 @@ #ifndef EDITOR_DIR_DIALOG_H #define EDITOR_DIR_DIALOG_H -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "editor/editor_file_system.h" #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 40313fbeff..f5652ab7b5 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -33,14 +33,14 @@ #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" #include "core/io/config_file.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" #include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/io/zip_io.h" #include "core/object/script_language.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/version.h" #include "editor/editor_file_system.h" #include "editor/plugins/script_editor_plugin.h" diff --git a/editor/editor_export.h b/editor/editor_export.h index c96c8fdbce..8474f4ef6d 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -31,8 +31,8 @@ #ifndef EDITOR_EXPORT_H #define EDITOR_EXPORT_H +#include "core/io/dir_access.h" #include "core/io/resource.h" -#include "core/os/dir_access.h" #include "scene/main/node.h" #include "scene/main/timer.h" #include "scene/resources/texture.h" diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index d232153206..51c6b473ad 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -30,8 +30,8 @@ #include "editor_feature_profile.h" +#include "core/io/dir_access.h" #include "core/io/json.h" -#include "core/os/dir_access.h" #include "editor/editor_settings.h" #include "editor_node.h" #include "editor_scale.h" diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index e118b5f287..8f4d09ea32 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -31,8 +31,8 @@ #ifndef EDITOR_FEATURE_PROFILE_H #define EDITOR_FEATURE_PROFILE_H +#include "core/io/file_access.h" #include "core/object/reference.h" -#include "core/os/file_access.h" #include "editor/editor_file_dialog.h" #include "editor_help.h" #include "scene/gui/dialogs.h" diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 75815fa750..e7d536e08e 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -30,7 +30,7 @@ #include "editor_file_dialog.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/print_string.h" diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 5a5e3a8807..f7879838d4 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -31,7 +31,7 @@ #ifndef EDITORFILEDIALOG_H #define EDITORFILEDIALOG_H -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "scene/gui/box_container.h" #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 69663b9ed9..050e55c624 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -31,10 +31,10 @@ #include "editor_file_system.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_importer.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/variant/variant_parser.h" #include "editor_node.h" diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 855c320856..04879bad6d 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -31,7 +31,7 @@ #ifndef EDITOR_FILE_SYSTEM_H #define EDITOR_FILE_SYSTEM_H -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/thread.h" #include "core/os/thread_safe.h" #include "core/templates/safe_refcount.h" diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 97a2c67c26..4030aecbf5 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -30,7 +30,7 @@ #include "editor_folding.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "editor_inspector.h" #include "editor_settings.h" diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8a5142459c..2f5451fba3 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -31,7 +31,7 @@ #include "editor_fonts.h" #include "builtin_fonts.gen.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "editor_scale.h" #include "editor_settings.h" #include "scene/resources/default_theme/default_theme.h" diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 22d04add18..b96103b07e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -34,13 +34,13 @@ #include "core/core_bind.h" #include "core/input/input.h" #include "core/io/config_file.h" +#include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/io/stream_peer_ssl.h" #include "core/object/class_db.h" #include "core/object/message_queue.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/print_string.h" diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp index 474da4fb96..ddba36c187 100644 --- a/editor/editor_paths.cpp +++ b/editor/editor_paths.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "editor_paths.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/os.h" EditorPaths *EditorPaths::singleton = nullptr; diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index e5b62513ff..1db24bb908 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -32,7 +32,7 @@ #include "core/config/project_settings.h" #include "core/io/config_file.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/main_loop.h" #include "editor_node.h" #include "editor_scale.h" diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 35cf08b4d7..d9520e0aa8 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -31,10 +31,10 @@ #include "editor_resource_preview.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/object/message_queue.h" -#include "core/os/file_access.h" #include "editor_node.h" #include "editor_scale.h" #include "editor_settings.h" diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 71dc1b531a..949638f0c9 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -35,13 +35,13 @@ #include "core/io/certs_compressed.gen.h" #include "core/io/compression.h" #include "core/io/config_file.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/file_access_memory.h" #include "core/io/ip.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/io/translation_loader_po.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/version.h" diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp index 49d5cf1fd3..75bdfa4796 100644 --- a/editor/editor_translation_parser.cpp +++ b/editor/editor_translation_parser.cpp @@ -31,8 +31,8 @@ #include "editor_translation_parser.h" #include "core/error/error_macros.h" +#include "core/io/file_access.h" #include "core/object/script_language.h" -#include "core/os/file_access.h" #include "core/templates/set.h" EditorTranslationParser *EditorTranslationParser::singleton = nullptr; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 39d7c7acd4..76c6fcc3d3 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -31,9 +31,9 @@ #include "export_template_manager.h" #include "core/input/input.h" +#include "core/io/dir_access.h" #include "core/io/json.h" #include "core/io/zip_io.h" -#include "core/os/dir_access.h" #include "core/os/keyboard.h" #include "core/version.h" #include "editor_node.h" diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index ce98f699ae..bd1aaf7611 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -31,9 +31,9 @@ #include "filesystem_dock.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/templates/list.h" diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 8783c402cd..12c567fb69 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -43,7 +43,7 @@ #include "scene/gui/tree.h" #include "scene/main/timer.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/thread.h" #include "create_dialog.h" diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index d9b956ed08..17d24a295c 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -30,7 +30,7 @@ #include "find_in_files.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/os.h" #include "editor_node.h" #include "editor_scale.h" diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 4a4d9d8f06..c9e446a1a2 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -30,8 +30,8 @@ #include "resource_importer_csv_translation.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "core/string/optimized_translation.h" #include "core/string/translation.h" diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp index c5b2a8dc3a..2dea359188 100644 --- a/editor/import/resource_importer_image.cpp +++ b/editor/import/resource_importer_image.cpp @@ -30,9 +30,9 @@ #include "resource_importer_image.h" +#include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "scene/resources/texture.h" String ResourceImporterImage::get_importer_name() const { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index dd62c72d8a..c592e4b031 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -30,8 +30,8 @@ #include "resource_importer_obj.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "editor/import/scene_importer_mesh.h" #include "editor/import/scene_importer_mesh_node_3d.h" #include "scene/3d/mesh_instance_3d.h" diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index f4d20a6296..70119bfd1c 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -30,9 +30,9 @@ #include "resource_importer_shader_file.h" +#include "core/io/file_access.h" #include "core/io/marshalls.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "editor/editor_node.h" #include "editor/plugins/shader_file_editor_plugin.h" #include "servers/rendering/rendering_device_binds.h" diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index 0d551a965c..41220009cd 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -31,9 +31,9 @@ #ifndef RESOURCEIMPORTTEXTURE_H #define RESOURCEIMPORTTEXTURE_H +#include "core/io/file_access.h" #include "core/io/image.h" #include "core/io/resource_importer.h" -#include "core/os/file_access.h" #include "scene/resources/texture.h" #include "servers/rendering_server.h" diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 4c3ae59951..d5d1a14be3 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -31,10 +31,10 @@ #include "resource_importer_texture_atlas.h" #include "atlas_import_failed.xpm" +#include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/resource_saver.h" #include "core/math/geometry_2d.h" -#include "core/os/file_access.h" #include "editor/editor_atlas_packer.h" #include "scene/resources/mesh.h" #include "scene/resources/texture.h" diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index bcc55b330b..e615212569 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -30,9 +30,9 @@ #include "resource_importer_wav.h" +#include "core/io/file_access.h" #include "core/io/marshalls.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "scene/resources/audio_stream_sample.h" const float TRIM_DB_LIMIT = -50; diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 7dda61f0bf..f55d77d782 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -30,7 +30,7 @@ #include "plugin_config_dialog.h" #include "core/io/config_file.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "editor/editor_scale.h" diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 6e71133c4f..a0df7e289e 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -32,8 +32,8 @@ #include "canvas_item_editor_plugin.h" #include "core/input/input.h" +#include "core/io/file_access.h" #include "core/math/geometry_2d.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "editor/editor_settings.h" #include "node_3d_editor_plugin.h" diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 208abeb87f..838e67b5e7 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "path_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index d2ea7a10dc..8a14db0cfd 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -32,8 +32,8 @@ #include "canvas_item_editor_plugin.h" #include "core/input/input.h" +#include "core/io/file_access.h" #include "core/math/geometry_2d.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d66217ec2d..b89992b03c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -32,8 +32,8 @@ #include "core/config/project_settings.h" #include "core/input/input.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "editor/debugger/editor_debugger_node.h" diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index f1c73f99dc..7d38a8cb98 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "theme_editor_plugin.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_scale.h" diff --git a/editor/pot_generator.h b/editor/pot_generator.h index ab055e0c0e..61300064ba 100644 --- a/editor/pot_generator.h +++ b/editor/pot_generator.h @@ -31,7 +31,7 @@ #ifndef POT_GENERATOR_H #define POT_GENERATOR_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/templates/ordered_hash_map.h" #include "core/templates/set.h" diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 9b99372735..d72028cd0a 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -31,11 +31,11 @@ #include "project_export.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/string/optimized_translation.h" #include "editor_data.h" diff --git a/editor/project_export.h b/editor/project_export.h index cfd4934c34..aeace708b8 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -31,7 +31,7 @@ #ifndef PROJECT_EXPORT_SETTINGS_H #define PROJECT_EXPORT_SETTINGS_H -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/thread.h" #include "editor/editor_export.h" #include "editor/editor_file_dialog.h" diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1b596ce599..12490f687e 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -31,11 +31,11 @@ #include "project_manager.h" #include "core/io/config_file.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" #include "core/io/stream_peer_ssl.h" #include "core/io/zip_io.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/translation.h" diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c2bfdaae96..650decfd49 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -31,9 +31,9 @@ #include "script_create_dialog.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" #include "core/object/script_language.h" -#include "core/os/file_access.h" #include "core/string/string_builder.h" #include "editor/create_dialog.h" #include "editor/editor_node.h" diff --git a/main/main.cpp b/main/main.cpp index d67761db55..c2e3cc8d58 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -36,6 +36,7 @@ #include "core/debugger/engine_debugger.h" #include "core/input/input.h" #include "core/input/input_map.h" +#include "core/io/dir_access.h" #include "core/io/file_access_network.h" #include "core/io/file_access_pack.h" #include "core/io/file_access_zip.h" @@ -43,7 +44,6 @@ #include "core/io/ip.h" #include "core/io/resource_loader.h" #include "core/object/message_queue.h" -#include "core/os/dir_access.h" #include "core/os/os.h" #include "core/register_core_types.h" #include "core/string/translation.h" diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 2fef576b77..fced61a600 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -30,7 +30,7 @@ #include "texture_loader_dds.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #define PF_FOURCC(s) ((uint32_t)(((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0]))) diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index fe0c92b22f..6c15eb7e12 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -33,8 +33,8 @@ #ifdef TOOLS_ENABLED +#include "core/io/file_access.h" #include "core/io/json.h" -#include "core/os/file_access.h" #include "core/string/ustring.h" #include "core/templates/local_vector.h" #include "core/templates/map.h" diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 7c3b76e4d7..e552f443cf 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -32,9 +32,9 @@ #include "core/config/project_settings.h" #include "core/core_constants.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "scene/main/scene_tree.h" diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index f184c84615..51e839f015 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -34,8 +34,8 @@ #include "core/config/engine.h" #include "core/core_constants.h" +#include "core/io/file_access.h" #include "core/object/class_db.h" -#include "core/os/file_access.h" #include "core/string/string_builder.h" #include "core/templates/pair.h" diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 03e25f49e6..3f705c7858 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -37,8 +37,8 @@ #include "core/config/project_settings.h" #include "core/core_constants.h" #include "core/core_string_names.h" +#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "main/main.h" diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 1360cf0299..0291ae560b 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -30,7 +30,7 @@ // Godot imports #include "core/config/project_settings.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" // PluginScript imports #include "pluginscript_language.h" diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp index f2165cd225..462452a897 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ // Godot imports -#include "core/os/file_access.h" +#include "core/io/file_access.h" // Pythonscript imports #include "pluginscript_language.h" #include "pluginscript_loader.h" diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 6bb11d3e8f..56fc7273f2 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ // Godot imports -#include "core/os/file_access.h" +#include "core/io/file_access.h" // PluginScript imports #include "pluginscript_instance.h" #include "pluginscript_script.h" diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp index b94538b2f7..433544178f 100644 --- a/modules/gdnative/pluginscript/register_types.cpp +++ b/modules/gdnative/pluginscript/register_types.cpp @@ -31,9 +31,9 @@ #include "register_types.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/dir_access.h" #include "core/os/os.h" #include "scene/main/scene_tree.h" diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index 140888cd4b..c605dbb433 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -32,7 +32,7 @@ #define VIDEO_STREAM_GDNATIVE_H #include "../gdnative.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "scene/resources/texture.h" #include "scene/resources/video_stream.h" diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index e99c3d6cca..77e6729b63 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -36,8 +36,8 @@ #include "core/config/project_settings.h" #include "core/core_constants.h" #include "core/core_string_names.h" +#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "gdscript_analyzer.h" #include "gdscript_cache.h" diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index e92adee8e8..e901b74616 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -31,10 +31,10 @@ #include "gdscript_analyzer.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/object/class_db.h" #include "core/object/script_language.h" -#include "core/os/file_access.h" #include "core/templates/hash_map.h" #include "gdscript.h" #include "gdscript_utility_functions.h" diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 601cdb4080..a3b1fb93f9 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -30,7 +30,7 @@ #include "gdscript_cache.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/templates/vector.h" #include "gdscript.h" #include "gdscript_analyzer.h" diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 504c7414f6..9aad14c2be 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -32,7 +32,7 @@ #include "core/config/engine.h" #include "core/core_constants.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "gdscript_analyzer.h" #include "gdscript_compiler.h" #include "gdscript_parser.h" diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1af54ea8df..ab40b99bb4 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -31,9 +31,9 @@ #include "gdscript_parser.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/math/math_defs.h" -#include "core/os/file_access.h" #include "gdscript.h" #ifdef DEBUG_ENABLED diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp index 340a7b9343..33597c286f 100644 --- a/modules/gdscript/language_server/gdscript_language_server.cpp +++ b/modules/gdscript/language_server/gdscript_language_server.cpp @@ -30,7 +30,7 @@ #include "gdscript_language_server.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #include "editor/editor_log.h" #include "editor/editor_node.h" diff --git a/modules/gdscript/language_server/gdscript_text_document.h b/modules/gdscript/language_server/gdscript_text_document.h index 792e601bc1..4696966e85 100644 --- a/modules/gdscript/language_server/gdscript_text_document.h +++ b/modules/gdscript/language_server/gdscript_text_document.h @@ -31,8 +31,8 @@ #ifndef GDSCRIPT_TEXT_DOCUMENT_H #define GDSCRIPT_TEXT_DOCUMENT_H +#include "core/io/file_access.h" #include "core/object/reference.h" -#include "core/os/file_access.h" #include "lsp.hpp" class GDScriptTextDocument : public Reference { diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 2d2f94f5e0..867142019f 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -30,10 +30,10 @@ #include "register_types.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" #include "core/io/resource_loader.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "gdscript.h" #include "gdscript_analyzer.h" #include "gdscript_cache.h" diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index e20e427597..cda348f774 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -37,8 +37,8 @@ #include "core/config/project_settings.h" #include "core/core_string_names.h" +#include "core/io/dir_access.h" #include "core/io/file_access_pack.h" -#include "core/os/dir_access.h" #include "core/os/os.h" #include "core/string/string_builder.h" #include "scene/resources/packed_scene.h" diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index fc73b5bb72..c37d52febd 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -31,8 +31,8 @@ #include "test_gdscript.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/file_access_pack.h" -#include "core/os/file_access.h" #include "core/os/main_loop.h" #include "core/os/os.h" #include "core/string/string_builder.h" diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp index 35f44ca122..21b4bb75fb 100644 --- a/modules/gltf/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor_scene_importer_gltf.cpp @@ -29,10 +29,10 @@ /*************************************************************************/ #include "core/crypto/crypto_core.h" +#include "core/io/file_access.h" #include "core/io/json.h" #include "core/math/disjoint_set.h" #include "core/math/math_defs.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "editor/import/resource_importer_scene.h" #include "modules/gltf/gltf_state.h" diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index fa93704fd9..bc4de76344 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -49,9 +49,9 @@ #include "core/core_bind.h" #include "core/crypto/crypto_core.h" +#include "core/io/file_access.h" #include "core/io/json.h" #include "core/math/disjoint_set.h" -#include "core/os/file_access.h" #include "core/variant/typed_array.h" #include "core/version.h" #include "core/version_hash.gen.h" diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp index c389609984..3cd2da3d85 100644 --- a/modules/mbedtls/crypto_mbedtls.cpp +++ b/modules/mbedtls/crypto_mbedtls.cpp @@ -30,7 +30,7 @@ #include "crypto_mbedtls.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/config/engine.h" #include "core/config/project_settings.h" diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp index d77d946a77..11c9f64e21 100644 --- a/modules/mbedtls/packet_peer_mbed_dtls.cpp +++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp @@ -31,8 +31,8 @@ #include "packet_peer_mbed_dtls.h" #include "mbedtls/platform_util.h" +#include "core/io/file_access.h" #include "core/io/stream_peer_ssl.h" -#include "core/os/file_access.h" int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) { if (buf == nullptr || len <= 0) { diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h index 30632018a8..f8f9502caf 100644 --- a/modules/mbedtls/ssl_context_mbedtls.h +++ b/modules/mbedtls/ssl_context_mbedtls.h @@ -33,7 +33,7 @@ #include "crypto_mbedtls.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/object/reference.h" diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp index 8e40451806..bc72b04fa4 100644 --- a/modules/mbedtls/stream_peer_mbedtls.cpp +++ b/modules/mbedtls/stream_peer_mbedtls.cpp @@ -30,8 +30,8 @@ #include "stream_peer_mbedtls.h" +#include "core/io/file_access.h" #include "core/io/stream_peer_tcp.h" -#include "core/os/file_access.h" int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) { if (buf == nullptr || len <= 0) { diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index 24ec206191..600bbe9bb5 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -35,7 +35,7 @@ #include "audio_stream_mp3.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" void AudioStreamPlaybackMP3::_mix_internal(AudioFrame *p_buffer, int p_frames) { ERR_FAIL_COND(!active); diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp index f5137965da..dc16125726 100644 --- a/modules/minimp3/resource_importer_mp3.cpp +++ b/modules/minimp3/resource_importer_mp3.cpp @@ -30,8 +30,8 @@ #include "resource_importer_mp3.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "scene/resources/texture.h" String ResourceImporterMP3::get_importer_name() const { diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index 553c6eca53..bd02ec0eac 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -33,8 +33,8 @@ #ifdef DEBUG_METHODS_ENABLED #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/json.h" -#include "core/os/file_access.h" #include "core/version.h" void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index ac248bcff8..80333321c3 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -37,8 +37,8 @@ #include "core/config/project_settings.h" #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" +#include "core/io/file_access.h" #include "core/io/json.h" -#include "core/os/file_access.h" #include "core/os/mutex.h" #include "core/os/os.h" #include "core/os/thread.h" diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 94c5195b83..adf19cfb8c 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -35,8 +35,8 @@ #include "core/config/engine.h" #include "core/core_constants.h" #include "core/io/compression.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #include "core/string/ucaps.h" #include "main/main.h" diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 68134b9b20..375ad413c4 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -31,7 +31,7 @@ #include "godotsharp_dirs.h" #include "core/config/project_settings.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/os.h" #ifdef TOOLS_ENABLED diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index c523d381f6..a3acfbd995 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -39,8 +39,8 @@ #include "core/config/project_settings.h" #include "core/debugger/engine_debugger.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #include "core/os/thread.h" diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index a1556bace5..67d6f3ef29 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -34,8 +34,8 @@ #include #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/file_access_pack.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/templates/list.h" diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index dafd36c36b..0537dc2ca3 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -32,7 +32,7 @@ #include // abort -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/os/os.h" #include "../godotsharp_dirs.h" diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h index f7a53156ab..9ddbd251ac 100644 --- a/modules/mono/mono_gd/gd_mono_log.h +++ b/modules/mono/mono_gd/gd_mono_log.h @@ -41,7 +41,7 @@ #endif #ifdef GD_MONO_LOG_ENABLED -#include "core/os/file_access.h" +#include "core/io/file_access.h" #endif class GDMonoLog { diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 6e0a263c7f..52bdc6ff01 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -35,8 +35,8 @@ #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" +#include "core/io/dir_access.h" #include "core/object/reference.h" -#include "core/os/dir_access.h" #include "core/os/mutex.h" #include "core/os/os.h" diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index bb1265e959..6b616dd52d 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "mono_reg_utils.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #ifdef WINDOWS_ENABLED diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 93d44628ac..3da2b06f7c 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -31,8 +31,8 @@ #include "path_utils.h" #include "core/config/project_settings.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #ifdef WINDOWS_ENABLED diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index ee68458268..053618ebe4 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -30,7 +30,7 @@ #include "string_utils.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include #include diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 83f032ca2b..cb12976090 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -30,7 +30,7 @@ #include "texture_loader_pvr.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" static void _pvrtc_decompress(Image *p_img); diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index e8e481de2d..78b4749939 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -30,7 +30,7 @@ #include "audio_stream_ogg_vorbis.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) { ERR_FAIL_COND(!active); diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp index e3aa630cef..a0de5e5f0f 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp @@ -30,8 +30,8 @@ #include "resource_importer_ogg_vorbis.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "scene/resources/texture.h" String ResourceImporterOGGVorbis::get_importer_name() const { diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 2685a8a013..760173d0df 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -31,8 +31,8 @@ #ifndef VIDEO_STREAM_THEORA_H #define VIDEO_STREAM_THEORA_H +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "core/os/semaphore.h" #include "core/os/thread.h" #include "core/templates/ring_buffer.h" diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 34addb5c9f..6ec0bde7bd 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -31,7 +31,7 @@ #include "video_stream_webm.h" #include "core/config/project_settings.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #include "servers/audio_server.h" diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index 7b9cbeea47..cdf98187ed 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -31,7 +31,7 @@ #ifndef DIR_ACCESS_JANDROID_H #define DIR_ACCESS_JANDROID_H -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "java_godot_lib_jni.h" #include diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index c45828e194..fe7c4d1b08 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -31,11 +31,11 @@ #include "export.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/marshalls.h" #include "core/io/zip_io.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/templates/safe_refcount.h" #include "core/version.h" diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index 0bb94dcc97..6ab678b8a1 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -31,9 +31,9 @@ #ifndef GODOT_GRADLE_EXPORT_UTIL_H #define GODOT_GRADLE_EXPORT_UTIL_H +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/zip_io.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "editor/editor_export.h" diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index 8890e0f645..bb4ce36947 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -31,7 +31,7 @@ #ifndef FILE_ACCESS_ANDROID_H #define FILE_ACCESS_ANDROID_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include #include #include diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 73723b98a0..e2df573b09 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -31,11 +31,11 @@ #include "export.h" #include "core/config/project_settings.h" +#include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/marshalls.h" #include "core/io/resource_saver.h" #include "core/io/zip_io.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/templates/safe_refcount.h" #include "core/version.h" diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 458834ce3a..1f08901082 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -33,9 +33,9 @@ #include "os_iphone.h" #import "app_delegate.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/file_access_pack.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "display_server_iphone.h" #include "drivers/unix/syslog_logger.h" #import "godot_view.h" diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp index b35ccd087f..83a0fcc68f 100644 --- a/platform/javascript/api/javascript_tools_editor_plugin.cpp +++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp @@ -33,8 +33,8 @@ #include "core/config/engine.h" #include "core/config/project_settings.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "editor/editor_node.h" #include diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp index cb95068314..3ee088dd35 100644 --- a/platform/linuxbsd/export/export.cpp +++ b/platform/linuxbsd/export/export.cpp @@ -30,7 +30,7 @@ #include "export.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "editor/editor_export.h" #include "platform/linuxbsd/logo.gen.h" #include "scene/resources/texture.h" diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 23e448fbd7..f112f4dde6 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -30,7 +30,7 @@ #include "os_linuxbsd.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "main/main.h" #ifdef X11_ENABLED diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h index f61581979f..a894723e64 100644 --- a/platform/osx/dir_access_osx.h +++ b/platform/osx/dir_access_osx.h @@ -38,7 +38,7 @@ #include #include -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "drivers/unix/dir_access_unix.h" class DirAccessOSX : public DirAccessUnix { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 6d995412ab..4055cae586 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -31,11 +31,11 @@ #include "export.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/marshalls.h" #include "core/io/resource_saver.h" #include "core/io/zip_io.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/version.h" #include "editor/editor_export.h" diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp index bac8620086..67f054aeaa 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app.cpp @@ -34,8 +34,8 @@ #include "app.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/os/keyboard.h" #include "main/main.h" diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 351aaa5957..1b14aac3da 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -33,11 +33,11 @@ #include "core/config/project_settings.h" #include "core/core_bind.h" #include "core/crypto/crypto_core.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/marshalls.h" #include "core/io/zip_io.h" #include "core/object/class_db.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/version.h" #include "editor/editor_export.h" #include "editor/editor_node.h" diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 222597b3ff..803d9371f5 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/os.h" #include "editor/editor_export.h" #include "editor/editor_node.h" diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index cc1177d541..a3f681e53c 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -31,11 +31,11 @@ #include "lightmap_gi.h" #include "core/io/config_file.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "core/io/resource_saver.h" #include "core/math/camera_matrix.h" #include "core/math/delaunay_3d.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/templates/sort_array.h" #include "lightmap_probe.h" diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 4996f00cb3..55774b488c 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -32,7 +32,7 @@ #define FILE_DIALOG_H #include "box_container.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "scene/gui/dialogs.h" #include "scene/gui/line_edit.h" #include "scene/gui/option_button.h" diff --git a/scene/main/http_request.h b/scene/main/http_request.h index 92b0ff28e9..22e822253f 100644 --- a/scene/main/http_request.h +++ b/scene/main/http_request.h @@ -31,8 +31,8 @@ #ifndef HTTPREQUEST_H #define HTTPREQUEST_H +#include "core/io/file_access.h" #include "core/io/http_client.h" -#include "core/os/file_access.h" #include "core/os/thread.h" #include "core/templates/safe_refcount.h" #include "node.h" diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 3e08f86fc9..e4ba93feec 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -33,10 +33,10 @@ #include "core/config/project_settings.h" #include "core/debugger/engine_debugger.h" #include "core/input/input.h" +#include "core/io/dir_access.h" #include "core/io/marshalls.h" #include "core/io/resource_loader.h" #include "core/object/message_queue.h" -#include "core/os/dir_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/print_string.h" diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index 9a9f019dda..81062feb46 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -30,8 +30,8 @@ #include "audio_stream_sample.h" +#include "core/io/file_access.h" #include "core/io/marshalls.h" -#include "core/os/file_access.h" void AudioStreamPlaybackSample::start(float p_from_pos) { if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) { diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 2414704a57..2a60f54fdd 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -31,14 +31,14 @@ #include "resource_format_text.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "core/io/resource_format_binary.h" -#include "core/os/dir_access.h" #include "core/version.h" //version 2: changed names for basis, aabb, Vectors, etc. #define FORMAT_VERSION 2 -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" #include "core/version.h" #define _printerr() ERR_PRINT(String(res_path + ":" + itos(lines) + " - Parse Error: " + error_text).utf8().get_data()); diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index 2dc683415d..f5d9cca859 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -31,9 +31,9 @@ #ifndef RESOURCE_FORMAT_TEXT_H #define RESOURCE_FORMAT_TEXT_H +#include "core/io/file_access.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/file_access.h" #include "core/variant/variant_parser.h" #include "scene/resources/packed_scene.h" diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 0ad21b0f0f..cbd44315b7 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -30,7 +30,7 @@ #include "shader.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "scene/scene_string_names.h" #include "servers/rendering/shader_language.h" #include "servers/rendering_server.h" diff --git a/scene/resources/text_file.cpp b/scene/resources/text_file.cpp index 564c65adb9..33bb0a83e9 100644 --- a/scene/resources/text_file.cpp +++ b/scene/resources/text_file.cpp @@ -30,7 +30,7 @@ #include "text_file.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" bool TextFile::has_text() const { return text != ""; diff --git a/scene/resources/texture.h b/scene/resources/texture.h index df8c00f8ff..1505e750f1 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -31,10 +31,10 @@ #ifndef TEXTURE_H #define TEXTURE_H +#include "core/io/file_access.h" #include "core/io/resource.h" #include "core/io/resource_loader.h" #include "core/math/rect2.h" -#include "core/os/file_access.h" #include "core/os/mutex.h" #include "core/os/rw_lock.h" #include "core/os/thread_safe.h" diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 12309f7488..d6a6f31fad 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "theme.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/string/print_string.h" void Theme::_emit_theme_changed() { diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h index b97ec43946..8f56e227e0 100644 --- a/servers/audio/effects/audio_effect_record.h +++ b/servers/audio/effects/audio_effect_record.h @@ -31,8 +31,8 @@ #ifndef AUDIOEFFECTRECORD_H #define AUDIOEFFECTRECORD_H +#include "core/io/file_access.h" #include "core/io/marshalls.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "core/os/thread.h" #include "editor/import/resource_importer_wav.h" diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 0e816fd4f8..acfdfa783a 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -32,8 +32,8 @@ #include "core/config/project_settings.h" #include "core/debugger/engine_debugger.h" +#include "core/io/file_access.h" #include "core/io/resource_loader.h" -#include "core/os/file_access.h" #include "core/os/os.h" #include "scene/resources/audio_stream_sample.h" #include "servers/audio/audio_driver_dummy.h" diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 1337d36762..f9ac7c8fa3 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -31,7 +31,7 @@ #include "renderer_compositor_rd.h" #include "core/config/project_settings.h" -#include "core/os/dir_access.h" +#include "core/io/dir_access.h" void RendererCompositorRD::prepare_for_blitting_render_targets() { RD::get_singleton()->prepare_screen_for_drawing(); diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index 6f29ff42bc..27305cc938 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -31,8 +31,8 @@ #include "shader_rd.h" #include "core/io/compression.h" -#include "core/os/dir_access.h" -#include "core/os/file_access.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" #include "renderer_compositor_rd.h" #include "servers/rendering/rendering_device.h" #include "thirdparty/misc/smolv.h" diff --git a/tests/test_file_access.h b/tests/test_file_access.h index 00a314644c..cb74e08a0d 100644 --- a/tests/test_file_access.h +++ b/tests/test_file_access.h @@ -31,7 +31,7 @@ #ifndef TEST_FILE_ACCESS_H #define TEST_FILE_ACCESS_H -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "test_utils.h" namespace TestFileAccess { diff --git a/tests/test_math.cpp b/tests/test_math.cpp index 7f2097699a..67d9a52539 100644 --- a/tests/test_math.cpp +++ b/tests/test_math.cpp @@ -30,13 +30,13 @@ #include "test_math.h" +#include "core/io/file_access.h" #include "core/math/basis.h" #include "core/math/camera_matrix.h" #include "core/math/delaunay_3d.h" #include "core/math/geometry_2d.h" #include "core/math/math_funcs.h" #include "core/math/transform_3d.h" -#include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/print_string.h" diff --git a/tests/test_shader_lang.cpp b/tests/test_shader_lang.cpp index 2169350c02..ad763b344e 100644 --- a/tests/test_shader_lang.cpp +++ b/tests/test_shader_lang.cpp @@ -30,7 +30,7 @@ #include "test_shader_lang.h" -#include "core/os/file_access.h" +#include "core/io/file_access.h" #include "core/os/main_loop.h" #include "core/os/os.h" -- cgit v1.2.3