From bddae4352f87aa44214e01afa51fef379f3b8696 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 19 Jan 2024 23:18:02 +0100 Subject: [PATCH] Renamed Fileaccess::open to FileAccess::create_and_open. --- sfw/core/dir_access.cpp | 4 ++-- sfw/core/file_access.cpp | 6 +++--- sfw/core/file_access.h | 4 ++-- sfw/render_core/image.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sfw/core/dir_access.cpp b/sfw/core/dir_access.cpp index c362816..7584b0b 100644 --- a/sfw/core/dir_access.cpp +++ b/sfw/core/dir_access.cpp @@ -1015,14 +1015,14 @@ String DirAccess::get_full_path(const String &p_path) { 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); + FileAccess *fsrc = FileAccess::create_and_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); + FileAccess *fdst = FileAccess::create_and_open(p_to, FileAccess::WRITE, &err); if (err) { fsrc->close(); memdelete(fsrc); diff --git a/sfw/core/file_access.cpp b/sfw/core/file_access.cpp index 03175a2..820cb61 100644 --- a/sfw/core/file_access.cpp +++ b/sfw/core/file_access.cpp @@ -679,7 +679,7 @@ FileAccess *FileAccess::create() { } bool FileAccess::exists(const String &p_name) { - FileAccess *f = open(p_name, READ); + FileAccess *f = create_and_open(p_name, READ); if (!f) { return false; } @@ -691,7 +691,7 @@ 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) { +FileAccess *FileAccess::create_and_open(const String &p_path, int p_mode_flags, Error *r_error) { //try packed data first FileAccess *ret = nullptr; @@ -1116,7 +1116,7 @@ void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) { */ Vector FileAccess::get_file_as_array(const String &p_path, Error *r_error) { - FileAccess *f = FileAccess::open(p_path, READ, r_error); + FileAccess *f = FileAccess::create_and_open(p_path, READ, r_error); if (!f) { if (r_error) { // if error requested, do not throw error return Vector(); diff --git a/sfw/core/file_access.h b/sfw/core/file_access.h index 96f8b09..8e8550b 100644 --- a/sfw/core/file_access.h +++ b/sfw/core/file_access.h @@ -126,8 +126,8 @@ public: virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType - static FileAccess *create(); /// Create a file access (for the current platform) this is the only portable way of accessing files. - 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 FileAccess *create(); /// Helper that Creates a file access + static FileAccess *create_and_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 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); diff --git a/sfw/render_core/image.cpp b/sfw/render_core/image.cpp index b1c9d33..dcaf5d4 100644 --- a/sfw/render_core/image.cpp +++ b/sfw/render_core/image.cpp @@ -1671,7 +1671,7 @@ Error Image::save_png(const String &file_name) { return FAILED; } - FileAccess* f = FileAccess::open(file_name, FileAccess::WRITE); + FileAccess* f = FileAccess::create_and_open(file_name, FileAccess::WRITE); if (!f) { return FAILED;