summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2023-02-16 15:25:32 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2023-02-16 15:34:20 +0200
commitbc95b0b17145e0e8df7e92ae5bea689112afab85 (patch)
tree3f8b1b171d14032e7508108caa50bdda44398d5d /core
parent953383328af17e8c9fd6359285c12617cb22f636 (diff)
Restore FileAccess.close method.
Diffstat (limited to 'core')
-rw-r--r--core/io/file_access.cpp2
-rw-r--r--core/io/file_access.h2
-rw-r--r--core/io/file_access_compressed.cpp4
-rw-r--r--core/io/file_access_compressed.h2
-rw-r--r--core/io/file_access_encrypted.cpp4
-rw-r--r--core/io/file_access_encrypted.h2
-rw-r--r--core/io/file_access_memory.h2
-rw-r--r--core/io/file_access_network.cpp9
-rw-r--r--core/io/file_access_network.h2
-rw-r--r--core/io/file_access_pack.cpp4
-rw-r--r--core/io/file_access_pack.h2
-rw-r--r--core/io/file_access_zip.cpp4
-rw-r--r--core/io/file_access_zip.h2
13 files changed, 41 insertions, 0 deletions
diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp
index cacbcb28a4..0e9084de84 100644
--- a/core/io/file_access.cpp
+++ b/core/io/file_access.cpp
@@ -856,6 +856,8 @@ void FileAccess::_bind_methods() {
ClassDB::bind_method(D_METHOD("store_pascal_string", "string"), &FileAccess::store_pascal_string);
ClassDB::bind_method(D_METHOD("get_pascal_string"), &FileAccess::get_pascal_string);
+ ClassDB::bind_method(D_METHOD("close"), &FileAccess::close);
+
ClassDB::bind_static_method("FileAccess", D_METHOD("file_exists", "path"), &FileAccess::exists);
ClassDB::bind_static_method("FileAccess", D_METHOD("get_modified_time", "file"), &FileAccess::get_modified_time);
diff --git a/core/io/file_access.h b/core/io/file_access.h
index 3e51ba11ed..47770cad87 100644
--- a/core/io/file_access.h
+++ b/core/io/file_access.h
@@ -166,6 +166,8 @@ public:
void store_var(const Variant &p_var, bool p_full_objects = false);
+ virtual void close() = 0;
+
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
diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp
index c256668af0..da59ae8c59 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -385,6 +385,10 @@ Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t
return FAILED;
}
+void FileAccessCompressed::close() {
+ _close();
+}
+
FileAccessCompressed::~FileAccessCompressed() {
_close();
}
diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h
index 136fcede06..601b74a9c1 100644
--- a/core/io/file_access_compressed.h
+++ b/core/io/file_access_compressed.h
@@ -97,6 +97,8 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file) override;
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override;
+ virtual void close() override;
+
FileAccessCompressed() {}
virtual ~FileAccessCompressed();
};
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index 8282f2515c..c39d19d52b 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -294,6 +294,10 @@ Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t
return ERR_UNAVAILABLE;
}
+void FileAccessEncrypted::close() {
+ _close();
+}
+
FileAccessEncrypted::~FileAccessEncrypted() {
_close();
}
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index d8cd0df6d1..9702b5a517 100644
--- a/core/io/file_access_encrypted.h
+++ b/core/io/file_access_encrypted.h
@@ -88,6 +88,8 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file) override;
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override;
+ virtual void close() override;
+
FileAccessEncrypted() {}
~FileAccessEncrypted();
};
diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h
index adc29f74be..43fe6ab658 100644
--- a/core/io/file_access_memory.h
+++ b/core/io/file_access_memory.h
@@ -71,6 +71,8 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file) override { return 0; }
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override { return FAILED; }
+ virtual void close() override {}
+
FileAccessMemory() {}
};
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index e765eb2d42..7fabff26ac 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -469,6 +469,15 @@ void FileAccessNetwork::configure() {
GLOBAL_DEF(PropertyInfo(Variant::INT, "network/remote_fs/page_read_ahead", PROPERTY_HINT_RANGE, "0,8,1,or_greater"), 4);
}
+void FileAccessNetwork::close() {
+ _close();
+
+ FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
+ nc->lock_mutex();
+ nc->accesses.erase(id);
+ nc->unlock_mutex();
+}
+
FileAccessNetwork::FileAccessNetwork() {
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
nc->lock_mutex();
diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h
index 16e8920114..78c19347ce 100644
--- a/core/io/file_access_network.h
+++ b/core/io/file_access_network.h
@@ -156,6 +156,8 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file) override;
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override;
+ virtual void close() override;
+
static void configure();
FileAccessNetwork();
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 7c392c005a..9553f35b19 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -366,6 +366,10 @@ bool FileAccessPack::file_exists(const String &p_name) {
return false;
}
+void FileAccessPack::close() {
+ f = Ref<FileAccess>();
+}
+
FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) :
pf(p_file),
f(FileAccess::open(pf.pack, FileAccess::READ)) {
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index baa62e4516..8bfabc9529 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -178,6 +178,8 @@ public:
virtual bool file_exists(const String &p_name) override;
+ virtual void close() override;
+
FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file);
};
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index b71dd5e9bd..064353476f 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -336,6 +336,10 @@ bool FileAccessZip::file_exists(const String &p_name) {
return false;
}
+void FileAccessZip::close() {
+ _close();
+}
+
FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) {
open_internal(p_path, FileAccess::READ);
}
diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h
index 63f1012f99..f8b640946c 100644
--- a/core/io/file_access_zip.h
+++ b/core/io/file_access_zip.h
@@ -109,6 +109,8 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file) override { return 0; }
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) override { return FAILED; }
+ virtual void close() override;
+
FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file);
~FileAccessZip();
};