summaryrefslogtreecommitdiff
path: root/editor/editor_asset_installer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_asset_installer.cpp')
-rw-r--r--editor/editor_asset_installer.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index 76c0811166..ef29448854 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -33,8 +33,9 @@
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/io/zip_io.h"
-#include "editor_node.h"
-#include "progress_dialog.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_node.h"
+#include "editor/progress_dialog.h"
void EditorAssetInstaller::_item_edited() {
if (updating) {
@@ -61,10 +62,10 @@ void EditorAssetInstaller::_check_propagated_to_item(Object *p_obj, int column)
void EditorAssetInstaller::open(const String &p_path, int p_depth) {
package_path = p_path;
- Set<String> files_sorted;
+ HashSet<String> files_sorted;
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ Ref<FileAccess> io_fa;
+ zlib_filefunc_def io = zipio_create_io(&io_fa);
unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io);
if (!pkg) {
@@ -86,7 +87,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
ret = unzGoToNextFile(pkg);
}
- Map<String, Ref<Texture2D>> extension_guess;
+ HashMap<String, Ref<Texture2D>> extension_guess;
{
extension_guess["bmp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
extension_guess["dds"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
@@ -149,12 +150,12 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
root->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog")));
root->set_text(0, "res://");
root->set_editable(0, true);
- Map<String, TreeItem *> dir_map;
+ HashMap<String, TreeItem *> dir_map;
int num_file_conflicts = 0;
- for (Set<String>::Element *E = files_sorted.front(); E; E = E->next()) {
- String path = E->get();
+ for (const String &E : files_sorted) {
+ String path = E;
int depth = p_depth;
bool skip = false;
while (depth > 0) {
@@ -223,7 +224,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
ti->set_metadata(0, res_path);
}
- status_map[E->get()] = ti;
+ status_map[E] = ti;
}
if (num_file_conflicts >= 1) {
@@ -237,8 +238,8 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
}
void EditorAssetInstaller::ok_pressed() {
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ Ref<FileAccess> io_fa;
+ zlib_filefunc_def io = zipio_create_io(&io_fa);
unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
if (!pkg) {
@@ -258,6 +259,9 @@ void EditorAssetInstaller::ok_pressed() {
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
+ if (ret != UNZ_OK) {
+ break;
+ }
String name = String::utf8(fname);
@@ -276,10 +280,8 @@ void EditorAssetInstaller::ok_pressed() {
dirpath = dirpath.substr(0, dirpath.length() - 1);
}
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
da->make_dir(dirpath);
- memdelete(da);
-
} else {
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
@@ -289,10 +291,9 @@ void EditorAssetInstaller::ok_pressed() {
unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
- FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE);
+ if (f.is_valid()) {
f->store_buffer(data.ptr(), data.size());
- memdelete(f);
} else {
failed_files.push_back(path);
}
@@ -357,7 +358,5 @@ EditorAssetInstaller::EditorAssetInstaller() {
get_ok_button()->set_text(TTR("Install"));
set_title(TTR("Asset Installer"));
- updating = false;
-
set_hide_on_ok(true);
}