summaryrefslogtreecommitdiff
path: root/platform/uwp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/uwp')
-rw-r--r--platform/uwp/export/export.cpp67
-rw-r--r--platform/uwp/os_uwp.cpp9
-rw-r--r--platform/uwp/os_uwp.h3
3 files changed, 26 insertions, 53 deletions
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 75ce422e9e..ea110b11ca 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -30,10 +30,11 @@
#include "export.h"
#include "core/bind/core_bind.h"
+#include "core/crypto/crypto_core.h"
#include "core/io/marshalls.h"
#include "core/io/zip_io.h"
-#include "core/math/crypto_core.h"
#include "core/object.h"
+#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/project_settings.h"
#include "core/version.h"
@@ -133,8 +134,6 @@ class AppxPackager {
String progress_task;
FileAccess *package;
- String tmp_blockmap_file_path;
- String tmp_content_types_file_path;
Set<String> mime_types;
@@ -146,8 +145,8 @@ class AppxPackager {
String hash_block(const uint8_t *p_block_data, size_t p_block_len);
- void make_block_map();
- void make_content_types();
+ void make_block_map(const String &p_path);
+ void make_content_types(const String &p_path);
_FORCE_INLINE_ unsigned int buf_put_int16(uint16_t p_val, uint8_t *p_buf) {
for (int i = 0; i < 2; i++) {
@@ -208,9 +207,9 @@ String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len)
return String(base64);
}
-void AppxPackager::make_block_map() {
+void AppxPackager::make_block_map(const String &p_path) {
- FileAccess *tmp_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::WRITE);
+ FileAccess *tmp_file = FileAccess::open(p_path, FileAccess::WRITE);
tmp_file->store_string("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
tmp_file->store_string("<BlockMap xmlns=\"http://schemas.microsoft.com/appx/2010/blockmap\" HashMethod=\"http://www.w3.org/2001/04/xmlenc#sha256\">");
@@ -253,9 +252,9 @@ String AppxPackager::content_type(String p_extension) {
return "application/octet-stream";
}
-void AppxPackager::make_content_types() {
+void AppxPackager::make_content_types(const String &p_path) {
- FileAccess *tmp_file = FileAccess::open(tmp_content_types_file_path, FileAccess::WRITE);
+ FileAccess *tmp_file = FileAccess::open(p_path, FileAccess::WRITE);
tmp_file->store_string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
tmp_file->store_string("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
@@ -458,8 +457,6 @@ void AppxPackager::init(FileAccess *p_fa) {
package = p_fa;
central_dir_offset = 0;
end_of_central_dir_offset = 0;
- tmp_blockmap_file_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpblockmap.xml");
- tmp_content_types_file_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpcontenttypes.xml");
}
Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress) {
@@ -591,7 +588,9 @@ void AppxPackager::finish() {
// Create and add block map file
EditorNode::progress_task_step("export", "Creating block map...", 4);
- make_block_map();
+ const String &tmp_blockmap_file_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpblockmap.xml");
+ make_block_map(tmp_blockmap_file_path);
+
FileAccess *blockmap_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::READ);
Vector<uint8_t> blockmap_buffer;
blockmap_buffer.resize(blockmap_file->get_len());
@@ -604,8 +603,11 @@ void AppxPackager::finish() {
memdelete(blockmap_file);
// Add content types
+
EditorNode::progress_task_step("export", "Setting content types...", 5);
- make_content_types();
+
+ const String &tmp_content_types_file_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpcontenttypes.xml");
+ make_content_types(tmp_content_types_file_path);
FileAccess *types_file = FileAccess::open(tmp_content_types_file_path, FileAccess::READ);
Vector<uint8_t> types_buffer;
@@ -618,6 +620,10 @@ void AppxPackager::finish() {
types_file->close();
memdelete(types_file);
+ // Cleanup generated files.
+ DirAccess::remove_file_or_error(tmp_blockmap_file_path);
+ DirAccess::remove_file_or_error(tmp_content_types_file_path);
+
// Pre-process central directory before signing
for (int i = 0; i < file_metadata.size(); i++) {
store_central_dir_header(file_metadata[i]);
@@ -901,8 +907,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
String err_string = "Couldn't save temp logo file.";
EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
+ ERR_FAIL_V_MSG(data, err_string);
}
FileAccess *f = FileAccess::open(tmp_path, FileAccess::READ, &err);
@@ -910,10 +915,10 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
if (err != OK) {
String err_string = "Couldn't open temp logo file.";
-
+ // Cleanup generated file.
+ DirAccess::remove_file_or_error(tmp_path);
EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
+ ERR_FAIL_V_MSG(data, err_string);
}
data.resize(f->get_len());
@@ -921,31 +926,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
f->close();
memdelete(f);
-
- // Delete temp file
- DirAccess *dir = DirAccess::open(tmp_path.get_base_dir(), &err);
-
- if (err != OK) {
-
- String err_string = "Couldn't open temp path to remove temp logo file.";
-
- EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
- }
-
- err = dir->remove(tmp_path);
-
- memdelete(dir);
-
- if (err != OK) {
-
- String err_string = "Couldn't remove temp logo file.";
-
- EditorNode::add_io_error(err_string);
- ERR_EXPLAIN(err_string);
- ERR_FAIL_V(data);
- }
+ DirAccess::remove_file_or_error(tmp_path);
return data;
}
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 9d9be44ce5..60f2290355 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -835,11 +835,7 @@ Error OS_UWP::open_dynamic_library(const String p_path, void *&p_library_handle,
String full_path = "game/" + p_path;
p_library_handle = (void *)LoadPackagedLibrary(full_path.c_str(), 0);
-
- if (!p_library_handle) {
- ERR_EXPLAIN("Can't open dynamic library: " + full_path + ". Error: " + format_error_message(GetLastError()));
- ERR_FAIL_V(ERR_CANT_OPEN);
- }
+ ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + full_path + ", error: " + format_error_message(GetLastError()) + ".");
return OK;
}
@@ -854,8 +850,7 @@ Error OS_UWP::get_dynamic_library_symbol_handle(void *p_library_handle, const St
p_symbol_handle = (void *)GetProcAddress((HMODULE)p_library_handle, p_name.utf8().get_data());
if (!p_symbol_handle) {
if (!p_optional) {
- ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + String::num(GetLastError()));
- ERR_FAIL_V(ERR_CANT_RESOLVE);
+ ERR_FAIL_V_MSG(ERR_CANT_RESOLVE, "Can't resolve symbol " + p_name + ", error: " + String::num(GetLastError()) + ".");
} else {
return ERR_CANT_RESOLVE;
}
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index b7a7248f19..370cab6a9b 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -50,9 +50,6 @@
#include <stdio.h>
#include <windows.h>
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
class OS_UWP : public OS {
public: