Merge pull request #34985 from bruvzg/macos_dmg_create_folders

macOS DMG export: create folder structure for the extracted files.
This commit is contained in:
Rémi Verschelde 2020-01-10 11:43:05 +01:00 committed by GitHub
commit abefd42e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 13 deletions

View File

@ -509,12 +509,13 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
io2.opaque = &dst_f; io2.opaque = &dst_f;
zipFile dst_pkg_zip = NULL; zipFile dst_pkg_zip = NULL;
DirAccess *tmp_app_path = NULL;
String export_format = use_dmg() && p_path.ends_with("dmg") ? "dmg" : "zip"; String export_format = use_dmg() && p_path.ends_with("dmg") ? "dmg" : "zip";
if (export_format == "dmg") { if (export_format == "dmg") {
// We're on OSX so we can export to DMG, but first we create our application bundle // We're on OSX so we can export to DMG, but first we create our application bundle
tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app"); tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app");
print_line("Exporting to " + tmp_app_path_name); print_line("Exporting to " + tmp_app_path_name);
DirAccess *tmp_app_path = DirAccess::create_for_path(tmp_app_path_name); tmp_app_path = DirAccess::create_for_path(tmp_app_path_name);
if (!tmp_app_path) { if (!tmp_app_path) {
err = ERR_CANT_CREATE; err = ERR_CANT_CREATE;
} }
@ -617,7 +618,10 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (export_format == "dmg") { if (export_format == "dmg") {
// write it into our application bundle // write it into our application bundle
file = tmp_app_path_name.plus_file(file); file = tmp_app_path_name.plus_file(file);
if (err == OK) {
err = tmp_app_path->make_dir_recursive(file.get_base_dir());
}
if (err == OK) {
// write the file, need to add chmod // write the file, need to add chmod
FileAccess *f = FileAccess::open(file, FileAccess::WRITE); FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
if (f) { if (f) {
@ -631,6 +635,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
} else { } else {
err = ERR_CANT_CREATE; err = ERR_CANT_CREATE;
} }
}
} else { } else {
// add it to our zip file // add it to our zip file
file = pkg_name + ".app/" + file; file = pkg_name + ".app/" + file;