Merge pull request #58986 from akien-mga/diraccessref
This commit is contained in:
commit
015fdfc28d
|
@ -145,7 +145,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
|
||||||
return p_path.simplify_path();
|
return p_path.simplify_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
|
|
||||||
String path = p_path.replace("\\", "/").simplify_path();
|
String path = p_path.replace("\\", "/").simplify_path();
|
||||||
|
|
||||||
|
@ -153,8 +153,6 @@ String ProjectSettings::localize_path(const String &p_path) const {
|
||||||
String cwd = dir->get_current_dir();
|
String cwd = dir->get_current_dir();
|
||||||
cwd = cwd.replace("\\", "/");
|
cwd = cwd.replace("\\", "/");
|
||||||
|
|
||||||
memdelete(dir);
|
|
||||||
|
|
||||||
// Ensure that we end with a '/'.
|
// Ensure that we end with a '/'.
|
||||||
// This is important to ensure that we do not wrongly localize the resource path
|
// This is important to ensure that we do not wrongly localize the resource path
|
||||||
// in an absolute path that just happens to contain this string but points to a
|
// in an absolute path that just happens to contain this string but points to a
|
||||||
|
@ -173,8 +171,6 @@ String ProjectSettings::localize_path(const String &p_path) const {
|
||||||
|
|
||||||
return cwd.replace_first(res_path, "res://");
|
return cwd.replace_first(res_path, "res://");
|
||||||
} else {
|
} else {
|
||||||
memdelete(dir);
|
|
||||||
|
|
||||||
int sep = path.rfind("/");
|
int sep = path.rfind("/");
|
||||||
if (sep == -1) {
|
if (sep == -1) {
|
||||||
return "res://" + path;
|
return "res://" + path;
|
||||||
|
@ -541,7 +537,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
|
||||||
// Nothing was found, try to find a project file in provided path (`p_path`)
|
// Nothing was found, try to find a project file in provided path (`p_path`)
|
||||||
// or, if requested (`p_upwards`) in parent directories.
|
// or, if requested (`p_upwards`) in parent directories.
|
||||||
|
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
ERR_FAIL_COND_V_MSG(!d, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_path + "'.");
|
ERR_FAIL_COND_V_MSG(!d, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_path + "'.");
|
||||||
d->change_dir(p_path);
|
d->change_dir(p_path);
|
||||||
|
|
||||||
|
@ -573,8 +569,6 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memdelete(d);
|
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1569,10 +1569,8 @@ String Directory::get_current_dir() {
|
||||||
Error Directory::make_dir(String p_dir) {
|
Error Directory::make_dir(String p_dir) {
|
||||||
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
|
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
|
||||||
if (!p_dir.is_relative_path()) {
|
if (!p_dir.is_relative_path()) {
|
||||||
DirAccess *d = DirAccess::create_for_path(p_dir);
|
DirAccessRef da = DirAccess::create_for_path(p_dir);
|
||||||
Error err = d->make_dir(p_dir);
|
return da->make_dir(p_dir);
|
||||||
memdelete(d);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
return d->make_dir(p_dir);
|
return d->make_dir(p_dir);
|
||||||
}
|
}
|
||||||
|
@ -1580,10 +1578,8 @@ Error Directory::make_dir(String p_dir) {
|
||||||
Error Directory::make_dir_recursive(String p_dir) {
|
Error Directory::make_dir_recursive(String p_dir) {
|
||||||
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
|
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
|
||||||
if (!p_dir.is_relative_path()) {
|
if (!p_dir.is_relative_path()) {
|
||||||
DirAccess *d = DirAccess::create_for_path(p_dir);
|
DirAccessRef da = DirAccess::create_for_path(p_dir);
|
||||||
Error err = d->make_dir_recursive(p_dir);
|
return da->make_dir_recursive(p_dir);
|
||||||
memdelete(d);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
return d->make_dir_recursive(p_dir);
|
return d->make_dir_recursive(p_dir);
|
||||||
}
|
}
|
||||||
|
@ -1593,19 +1589,14 @@ bool Directory::file_exists(String p_file) {
|
||||||
if (!p_file.is_relative_path()) {
|
if (!p_file.is_relative_path()) {
|
||||||
return FileAccess::exists(p_file);
|
return FileAccess::exists(p_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->file_exists(p_file);
|
return d->file_exists(p_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Directory::dir_exists(String p_dir) {
|
bool Directory::dir_exists(String p_dir) {
|
||||||
ERR_FAIL_COND_V_MSG(!d, false, "Directory is not configured properly.");
|
ERR_FAIL_COND_V_MSG(!d, false, "Directory is not configured properly.");
|
||||||
if (!p_dir.is_relative_path()) {
|
if (!p_dir.is_relative_path()) {
|
||||||
DirAccess *d = DirAccess::create_for_path(p_dir);
|
return DirAccess::exists(p_dir);
|
||||||
bool exists = d->dir_exists(p_dir);
|
|
||||||
memdelete(d);
|
|
||||||
return exists;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->dir_exists(p_dir);
|
return d->dir_exists(p_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1624,11 +1615,9 @@ Error Directory::rename(String p_from, String p_to) {
|
||||||
ERR_FAIL_COND_V_MSG(p_from.is_empty() || p_from == "." || p_from == "..", ERR_INVALID_PARAMETER, "Invalid path to rename.");
|
ERR_FAIL_COND_V_MSG(p_from.is_empty() || p_from == "." || p_from == "..", ERR_INVALID_PARAMETER, "Invalid path to rename.");
|
||||||
|
|
||||||
if (!p_from.is_relative_path()) {
|
if (!p_from.is_relative_path()) {
|
||||||
DirAccess *d = DirAccess::create_for_path(p_from);
|
DirAccessRef da = DirAccess::create_for_path(p_from);
|
||||||
ERR_FAIL_COND_V_MSG(!d->file_exists(p_from) && !d->dir_exists(p_from), ERR_DOES_NOT_EXIST, "File or directory does not exist.");
|
ERR_FAIL_COND_V_MSG(!da->file_exists(p_from) && !da->dir_exists(p_from), ERR_DOES_NOT_EXIST, "File or directory does not exist.");
|
||||||
Error err = d->rename(p_from, p_to);
|
return da->rename(p_from, p_to);
|
||||||
memdelete(d);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ERR_FAIL_COND_V_MSG(!d->file_exists(p_from) && !d->dir_exists(p_from), ERR_DOES_NOT_EXIST, "File or directory does not exist.");
|
ERR_FAIL_COND_V_MSG(!d->file_exists(p_from) && !d->dir_exists(p_from), ERR_DOES_NOT_EXIST, "File or directory does not exist.");
|
||||||
|
@ -1638,10 +1627,8 @@ Error Directory::rename(String p_from, String p_to) {
|
||||||
Error Directory::remove(String p_name) {
|
Error Directory::remove(String p_name) {
|
||||||
ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
|
ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
|
||||||
if (!p_name.is_relative_path()) {
|
if (!p_name.is_relative_path()) {
|
||||||
DirAccess *d = DirAccess::create_for_path(p_name);
|
DirAccessRef da = DirAccess::create_for_path(p_name);
|
||||||
Error err = d->remove(p_name);
|
return da->remove(p_name);
|
||||||
memdelete(d);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->remove(p_name);
|
return d->remove(p_name);
|
||||||
|
@ -1664,7 +1651,6 @@ void Directory::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("make_dir_recursive", "path"), &Directory::make_dir_recursive);
|
ClassDB::bind_method(D_METHOD("make_dir_recursive", "path"), &Directory::make_dir_recursive);
|
||||||
ClassDB::bind_method(D_METHOD("file_exists", "path"), &Directory::file_exists);
|
ClassDB::bind_method(D_METHOD("file_exists", "path"), &Directory::file_exists);
|
||||||
ClassDB::bind_method(D_METHOD("dir_exists", "path"), &Directory::dir_exists);
|
ClassDB::bind_method(D_METHOD("dir_exists", "path"), &Directory::dir_exists);
|
||||||
//ClassDB::bind_method(D_METHOD("get_modified_time","file"),&Directory::get_modified_time);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_space_left"), &Directory::get_space_left);
|
ClassDB::bind_method(D_METHOD("get_space_left"), &Directory::get_space_left);
|
||||||
ClassDB::bind_method(D_METHOD("copy", "from", "to"), &Directory::copy);
|
ClassDB::bind_method(D_METHOD("copy", "from", "to"), &Directory::copy);
|
||||||
ClassDB::bind_method(D_METHOD("rename", "from", "to"), &Directory::rename);
|
ClassDB::bind_method(D_METHOD("rename", "from", "to"), &Directory::rename);
|
||||||
|
|
|
@ -414,8 +414,6 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DirAccess::exists(String p_dir) {
|
bool DirAccess::exists(String p_dir) {
|
||||||
DirAccess *da = DirAccess::create_for_path(p_dir);
|
DirAccessRef da = DirAccess::create_for_path(p_dir);
|
||||||
bool valid = da->change_dir(p_dir) == OK;
|
return da->change_dir(p_dir) == OK;
|
||||||
memdelete(da);
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ struct DirAccessRef {
|
||||||
|
|
||||||
operator bool() const { return f != nullptr; }
|
operator bool() const { return f != nullptr; }
|
||||||
|
|
||||||
DirAccess *f;
|
DirAccess *f = nullptr;
|
||||||
|
|
||||||
DirAccessRef(DirAccess *fa) { f = fa; }
|
DirAccessRef(DirAccess *fa) { f = fa; }
|
||||||
~DirAccessRef() {
|
~DirAccessRef() {
|
||||||
|
|
|
@ -128,7 +128,7 @@ void RotatedFileLogger::clear_old_backups() {
|
||||||
String basename = base_path.get_file().get_basename();
|
String basename = base_path.get_file().get_basename();
|
||||||
String extension = base_path.get_extension();
|
String extension = base_path.get_extension();
|
||||||
|
|
||||||
DirAccess *da = DirAccess::open(base_path.get_base_dir());
|
DirAccessRef da = DirAccess::open(base_path.get_base_dir());
|
||||||
if (!da) {
|
if (!da) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -152,8 +152,6 @@ void RotatedFileLogger::clear_old_backups() {
|
||||||
da->remove(E->get());
|
da->remove(E->get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotatedFileLogger::rotate_file() {
|
void RotatedFileLogger::rotate_file() {
|
||||||
|
@ -167,18 +165,16 @@ void RotatedFileLogger::rotate_file() {
|
||||||
backup_name += "." + base_path.get_extension();
|
backup_name += "." + base_path.get_extension();
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::open(base_path.get_base_dir());
|
DirAccessRef da = DirAccess::open(base_path.get_base_dir());
|
||||||
if (da) {
|
if (da) {
|
||||||
da->copy(base_path, backup_name);
|
da->copy(base_path, backup_name);
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
clear_old_backups();
|
clear_old_backups();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_USERDATA);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_USERDATA);
|
||||||
if (da) {
|
if (da) {
|
||||||
da->make_dir_recursive(base_path.get_base_dir());
|
da->make_dir_recursive(base_path.get_base_dir());
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1032,7 +1032,6 @@ RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_origi
|
||||||
String path = !p_original_path.is_empty() ? p_original_path : p_path;
|
String path = !p_original_path.is_empty() ? p_original_path : p_path;
|
||||||
loader.local_path = ProjectSettings::get_singleton()->localize_path(path);
|
loader.local_path = ProjectSettings::get_singleton()->localize_path(path);
|
||||||
loader.res_path = loader.local_path;
|
loader.res_path = loader.local_path;
|
||||||
//loader.set_local_path( Globals::get_singleton()->localize_path(p_path) );
|
|
||||||
loader.open(f);
|
loader.open(f);
|
||||||
|
|
||||||
err = loader.load();
|
err = loader.load();
|
||||||
|
@ -1086,17 +1085,14 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<Str
|
||||||
ResourceLoaderBinary loader;
|
ResourceLoaderBinary loader;
|
||||||
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
||||||
loader.res_path = loader.local_path;
|
loader.res_path = loader.local_path;
|
||||||
//loader.set_local_path( Globals::get_singleton()->localize_path(p_path) );
|
|
||||||
loader.get_dependencies(f, p_dependencies, p_add_types);
|
loader.get_dependencies(f, p_dependencies, p_add_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
|
Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
|
||||||
//Error error=OK;
|
|
||||||
|
|
||||||
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
|
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
|
||||||
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_path + "'.");
|
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_path + "'.");
|
||||||
|
|
||||||
FileAccess *fw = nullptr; //=FileAccess::open(p_path+".depren");
|
FileAccess *fw = nullptr;
|
||||||
|
|
||||||
String local_path = p_path.get_base_dir();
|
String local_path = p_path.get_base_dir();
|
||||||
|
|
||||||
|
@ -1158,10 +1154,12 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
|
||||||
if (ver_format < FORMAT_VERSION_CAN_RENAME_DEPS) {
|
if (ver_format < FORMAT_VERSION_CAN_RENAME_DEPS) {
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
memdelete(fw);
|
memdelete(fw);
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
{
|
||||||
da->remove(p_path + ".depren");
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
memdelete(da);
|
da->remove(p_path + ".depren");
|
||||||
//use the old approach
|
}
|
||||||
|
|
||||||
|
// Use the old approach.
|
||||||
|
|
||||||
WARN_PRINT("This file is old, so it can't refactor dependencies, opening and resaving '" + p_path + "'.");
|
WARN_PRINT("This file is old, so it can't refactor dependencies, opening and resaving '" + p_path + "'.");
|
||||||
|
|
||||||
|
@ -1174,7 +1172,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
|
||||||
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
||||||
loader.res_path = loader.local_path;
|
loader.res_path = loader.local_path;
|
||||||
loader.remaps = p_map;
|
loader.remaps = p_map;
|
||||||
//loader.set_local_path( Globals::get_singleton()->localize_path(p_path) );
|
|
||||||
loader.open(f);
|
loader.open(f);
|
||||||
|
|
||||||
err = loader.load();
|
err = loader.load();
|
||||||
|
@ -1304,10 +1301,9 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
|
||||||
return ERR_CANT_CREATE;
|
return ERR_CANT_CREATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
da->remove(p_path);
|
da->remove(p_path);
|
||||||
da->rename(p_path + ".depren", p_path);
|
da->rename(p_path + ".depren", p_path);
|
||||||
memdelete(da);
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,7 +1316,6 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const
|
||||||
ResourceLoaderBinary loader;
|
ResourceLoaderBinary loader;
|
||||||
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
||||||
loader.res_path = loader.local_path;
|
loader.res_path = loader.local_path;
|
||||||
//loader.set_local_path( Globals::get_singleton()->localize_path(p_path) );
|
|
||||||
String r = loader.recognize(f);
|
String r = loader.recognize(f);
|
||||||
return ClassDB::get_compatibility_remapped_class(r);
|
return ClassDB::get_compatibility_remapped_class(r);
|
||||||
}
|
}
|
||||||
|
@ -1339,7 +1334,6 @@ ResourceUID::ID ResourceFormatLoaderBinary::get_resource_uid(const String &p_pat
|
||||||
ResourceLoaderBinary loader;
|
ResourceLoaderBinary loader;
|
||||||
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
|
||||||
loader.res_path = loader.local_path;
|
loader.res_path = loader.local_path;
|
||||||
//loader.set_local_path( Globals::get_singleton()->localize_path(p_path) );
|
|
||||||
loader.open(f, true);
|
loader.open(f, true);
|
||||||
if (loader.error != OK) {
|
if (loader.error != OK) {
|
||||||
return ResourceUID::INVALID_ID; //could not read
|
return ResourceUID::INVALID_ID; //could not read
|
||||||
|
|
|
@ -328,17 +328,13 @@ void OS::yield() {
|
||||||
|
|
||||||
void OS::ensure_user_data_dir() {
|
void OS::ensure_user_data_dir() {
|
||||||
String dd = get_user_data_dir();
|
String dd = get_user_data_dir();
|
||||||
DirAccess *da = DirAccess::open(dd);
|
if (DirAccess::exists(dd)) {
|
||||||
if (da) {
|
|
||||||
memdelete(da);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
Error err = da->make_dir_recursive(dd);
|
Error err = da->make_dir_recursive(dd);
|
||||||
ERR_FAIL_COND_MSG(err != OK, "Error attempting to create data dir: " + dd + ".");
|
ERR_FAIL_COND_MSG(err != OK, "Error attempting to create data dir: " + dd + ".");
|
||||||
|
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String OS::get_model_name() const {
|
String OS::get_model_name() const {
|
||||||
|
|
|
@ -749,12 +749,11 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrphanResourcesDialog::_delete_confirm() {
|
void OrphanResourcesDialog::_delete_confirm() {
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
for (const String &E : paths) {
|
for (const String &E : paths) {
|
||||||
da->remove(E);
|
da->remove(E);
|
||||||
EditorFileSystem::get_singleton()->update_file(E);
|
EditorFileSystem::get_singleton()->update_file(E);
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,10 +277,8 @@ void EditorAssetInstaller::ok_pressed() {
|
||||||
dirpath = dirpath.substr(0, dirpath.length() - 1);
|
dirpath = dirpath.substr(0, dirpath.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
da->make_dir(dirpath);
|
da->make_dir(dirpath);
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Vector<uint8_t> data;
|
Vector<uint8_t> data;
|
||||||
data.resize(info.uncompressed_size);
|
data.resize(info.uncompressed_size);
|
||||||
|
|
|
@ -1094,12 +1094,11 @@ void EditorFileSystem::_delete_internal_files(String p_file) {
|
||||||
if (FileAccess::exists(p_file + ".import")) {
|
if (FileAccess::exists(p_file + ".import")) {
|
||||||
List<String> paths;
|
List<String> paths;
|
||||||
ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths);
|
ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths);
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
for (const String &E : paths) {
|
for (const String &E : paths) {
|
||||||
da->remove(E);
|
da->remove(E);
|
||||||
}
|
}
|
||||||
da->remove(p_file + ".import");
|
da->remove(p_file + ".import");
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ Ref<FontData> load_cached_internal_font(const uint8_t *p_data, size_t p_size, Te
|
||||||
}
|
}
|
||||||
|
|
||||||
void editor_register_fonts(Ref<Theme> p_theme) {
|
void editor_register_fonts(Ref<Theme> p_theme) {
|
||||||
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
|
|
||||||
/* Custom font */
|
/* Custom font */
|
||||||
|
|
||||||
|
@ -236,8 +236,6 @@ void editor_register_fonts(Ref<Theme> p_theme) {
|
||||||
EditorSettings::get_singleton()->set_manually("interface/editor/code_font", "");
|
EditorSettings::get_singleton()->set_manually("interface/editor/code_font", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
memdelete(dir);
|
|
||||||
|
|
||||||
/* Noto Sans */
|
/* Noto Sans */
|
||||||
|
|
||||||
Ref<FontData> DefaultFont = load_cached_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiased, true, font_subpixel_positioning);
|
Ref<FontData> DefaultFont = load_cached_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiased, true, font_subpixel_positioning);
|
||||||
|
|
|
@ -1222,7 +1222,7 @@ bool EditorSettings::is_dark_theme() {
|
||||||
void EditorSettings::list_text_editor_themes() {
|
void EditorSettings::list_text_editor_themes() {
|
||||||
String themes = "Default,Godot 2,Custom";
|
String themes = "Default,Godot 2,Custom";
|
||||||
|
|
||||||
DirAccess *d = DirAccess::open(get_text_editor_themes_dir());
|
DirAccessRef d = DirAccess::open(get_text_editor_themes_dir());
|
||||||
if (d) {
|
if (d) {
|
||||||
List<String> custom_themes;
|
List<String> custom_themes;
|
||||||
d->list_dir_begin();
|
d->list_dir_begin();
|
||||||
|
@ -1234,7 +1234,6 @@ void EditorSettings::list_text_editor_themes() {
|
||||||
file = d->get_next();
|
file = d->get_next();
|
||||||
}
|
}
|
||||||
d->list_dir_end();
|
d->list_dir_end();
|
||||||
memdelete(d);
|
|
||||||
|
|
||||||
custom_themes.sort();
|
custom_themes.sort();
|
||||||
for (const String &E : custom_themes) {
|
for (const String &E : custom_themes) {
|
||||||
|
@ -1289,10 +1288,9 @@ bool EditorSettings::import_text_editor_theme(String p_file) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *d = DirAccess::open(get_text_editor_themes_dir());
|
DirAccessRef d = DirAccess::open(get_text_editor_themes_dir());
|
||||||
if (d) {
|
if (d) {
|
||||||
d->copy(p_file, get_text_editor_themes_dir().plus_file(p_file.get_file()));
|
d->copy(p_file, get_text_editor_themes_dir().plus_file(p_file.get_file()));
|
||||||
memdelete(d);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1342,7 +1340,7 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c
|
||||||
if (!p_custom_path.is_empty()) {
|
if (!p_custom_path.is_empty()) {
|
||||||
template_dir = p_custom_path;
|
template_dir = p_custom_path;
|
||||||
}
|
}
|
||||||
DirAccess *d = DirAccess::open(template_dir);
|
DirAccessRef d = DirAccess::open(template_dir);
|
||||||
if (d) {
|
if (d) {
|
||||||
d->list_dir_begin();
|
d->list_dir_begin();
|
||||||
String file = d->get_next();
|
String file = d->get_next();
|
||||||
|
@ -1353,7 +1351,6 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c
|
||||||
file = d->get_next();
|
file = d->get_next();
|
||||||
}
|
}
|
||||||
d->list_dir_end();
|
d->list_dir_end();
|
||||||
memdelete(d);
|
|
||||||
}
|
}
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
void ExportTemplateManager::_update_template_status() {
|
void ExportTemplateManager::_update_template_status() {
|
||||||
// Fetch installed templates from the file system.
|
// Fetch installed templates from the file system.
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
|
const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
|
||||||
|
|
||||||
Error err = da->change_dir(templates_dir);
|
Error err = da->change_dir(templates_dir);
|
||||||
|
@ -62,7 +62,6 @@ void ExportTemplateManager::_update_template_status() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
da->list_dir_end();
|
da->list_dir_end();
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
// Update the state of the current version.
|
// Update the state of the current version.
|
||||||
String current_version = VERSION_FULL_CONFIG;
|
String current_version = VERSION_FULL_CONFIG;
|
||||||
|
|
|
@ -525,16 +525,14 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
|
||||||
if (target_path.ends_with("/")) {
|
if (target_path.ends_with("/")) {
|
||||||
target_path = target_path.substr(0, target_path.length() - 1);
|
target_path = target_path.substr(0, target_path.length() - 1);
|
||||||
}
|
}
|
||||||
DirAccess *dirAccess = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
if (dirAccess->file_exists(p_path)) {
|
if (da->file_exists(p_path)) {
|
||||||
path = target_path;
|
path = target_path;
|
||||||
} else if (dirAccess->dir_exists(p_path)) {
|
} else if (da->dir_exists(p_path)) {
|
||||||
path = target_path + "/";
|
path = target_path + "/";
|
||||||
} else {
|
} else {
|
||||||
memdelete(dirAccess);
|
|
||||||
ERR_FAIL_MSG(vformat("Cannot navigate to '%s' as it has not been found in the file system!", p_path));
|
ERR_FAIL_MSG(vformat("Cannot navigate to '%s' as it has not been found in the file system!", p_path));
|
||||||
}
|
}
|
||||||
memdelete(dirAccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_set_current_path_text(path);
|
_set_current_path_text(path);
|
||||||
|
@ -1171,7 +1169,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
||||||
_get_all_items_in_dir(EditorFileSystem::get_singleton()->get_filesystem_path(old_path), file_changed_paths, folder_changed_paths);
|
_get_all_items_in_dir(EditorFileSystem::get_singleton()->get_filesystem_path(old_path), file_changed_paths, folder_changed_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
print_verbose("Moving " + old_path + " -> " + new_path);
|
print_verbose("Moving " + old_path + " -> " + new_path);
|
||||||
Error err = da->rename(old_path, new_path);
|
Error err = da->rename(old_path, new_path);
|
||||||
if (err == OK) {
|
if (err == OK) {
|
||||||
|
@ -1211,7 +1209,6 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
||||||
} else {
|
} else {
|
||||||
EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n");
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n");
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const {
|
void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const {
|
||||||
|
@ -1230,7 +1227,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
print_verbose("Duplicating " + old_path + " -> " + new_path);
|
print_verbose("Duplicating " + old_path + " -> " + new_path);
|
||||||
Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path);
|
Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path);
|
||||||
if (err == OK) {
|
if (err == OK) {
|
||||||
|
@ -1268,7 +1265,6 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
|
||||||
} else {
|
} else {
|
||||||
EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n");
|
EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n");
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const {
|
void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const {
|
||||||
|
@ -1418,12 +1414,11 @@ void FileSystemDock::_make_dir_confirm() {
|
||||||
directory = directory.get_base_dir();
|
directory = directory.get_base_dir();
|
||||||
}
|
}
|
||||||
print_verbose("Making folder " + dir_name + " in " + directory);
|
print_verbose("Making folder " + dir_name + " in " + directory);
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
Error err = da->change_dir(directory);
|
Error err = da->change_dir(directory);
|
||||||
if (err == OK) {
|
if (err == OK) {
|
||||||
err = da->make_dir(dir_name);
|
err = da->make_dir(dir_name);
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
if (err == OK) {
|
if (err == OK) {
|
||||||
print_verbose("FileSystem: calling rescan.");
|
print_verbose("FileSystem: calling rescan.");
|
||||||
|
@ -1464,13 +1459,11 @@ void FileSystemDock::_make_scene_confirm() {
|
||||||
|
|
||||||
scene_name = directory.plus_file(scene_name);
|
scene_name = directory.plus_file(scene_name);
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
if (da->file_exists(scene_name)) {
|
if (da->file_exists(scene_name)) {
|
||||||
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
||||||
memdelete(da);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
int idx = EditorNode::get_singleton()->new_scene();
|
int idx = EditorNode::get_singleton()->new_scene();
|
||||||
EditorNode::get_singleton()->get_editor_data().set_scene_path(idx, scene_name);
|
EditorNode::get_singleton()->get_editor_data().set_scene_path(idx, scene_name);
|
||||||
|
@ -1533,7 +1526,7 @@ void FileSystemDock::_rename_operation_confirm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present a more user friendly warning for name conflict.
|
// Present a more user friendly warning for name conflict.
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
#if defined(WINDOWS_ENABLED) || defined(UWP_ENABLED)
|
#if defined(WINDOWS_ENABLED) || defined(UWP_ENABLED)
|
||||||
// Workaround case insensitivity on Windows.
|
// Workaround case insensitivity on Windows.
|
||||||
if ((da->file_exists(new_path) || da->dir_exists(new_path)) && new_path.to_lower() != old_path.to_lower()) {
|
if ((da->file_exists(new_path) || da->dir_exists(new_path)) && new_path.to_lower() != old_path.to_lower()) {
|
||||||
|
@ -1541,10 +1534,8 @@ void FileSystemDock::_rename_operation_confirm() {
|
||||||
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
|
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
|
||||||
#endif
|
#endif
|
||||||
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
||||||
memdelete(da);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
Map<String, String> file_renames;
|
Map<String, String> file_renames;
|
||||||
Map<String, String> folder_renames;
|
Map<String, String> folder_renames;
|
||||||
|
@ -1588,13 +1579,11 @@ void FileSystemDock::_duplicate_operation_confirm() {
|
||||||
String new_path = base_dir.plus_file(new_name);
|
String new_path = base_dir.plus_file(new_name);
|
||||||
|
|
||||||
// Present a more user friendly warning for name conflict
|
// Present a more user friendly warning for name conflict
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
|
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
|
||||||
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
|
||||||
memdelete(da);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
_try_duplicate_item(to_duplicate, new_path);
|
_try_duplicate_item(to_duplicate, new_path);
|
||||||
|
|
||||||
|
@ -2818,7 +2807,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::open(p_path);
|
DirAccessRef da = DirAccess::open(p_path);
|
||||||
da->list_dir_begin();
|
da->list_dir_begin();
|
||||||
String n = da->get_next();
|
String n = da->get_next();
|
||||||
while (!n.is_empty()) {
|
while (!n.is_empty()) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ void PluginConfigDialog::_on_confirmed() {
|
||||||
String path = "res://addons/" + subfolder_edit->get_text();
|
String path = "res://addons/" + subfolder_edit->get_text();
|
||||||
|
|
||||||
if (!_edit_mode) {
|
if (!_edit_mode) {
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
if (!d || d->make_dir_recursive(path) != OK) {
|
if (!d || d->make_dir_recursive(path) != OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
String _test_path() {
|
String _test_path() {
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
String valid_path, valid_install_path;
|
String valid_path, valid_install_path;
|
||||||
if (d->change_dir(project_path->get_text()) == OK) {
|
if (d->change_dir(project_path->get_text()) == OK) {
|
||||||
valid_path = project_path->get_text();
|
valid_path = project_path->get_text();
|
||||||
|
@ -165,7 +165,6 @@ private:
|
||||||
|
|
||||||
if (valid_path.is_empty()) {
|
if (valid_path.is_empty()) {
|
||||||
set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR);
|
set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -179,7 +178,6 @@ private:
|
||||||
|
|
||||||
if (valid_install_path.is_empty()) {
|
if (valid_install_path.is_empty()) {
|
||||||
set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH);
|
set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -194,7 +192,6 @@ private:
|
||||||
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
|
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
|
||||||
if (!pkg) {
|
if (!pkg) {
|
||||||
set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR);
|
set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
unzClose(pkg);
|
unzClose(pkg);
|
||||||
return "";
|
return "";
|
||||||
|
@ -215,7 +212,6 @@ private:
|
||||||
|
|
||||||
if (ret == UNZ_END_OF_LIST_OF_FILE) {
|
if (ret == UNZ_END_OF_LIST_OF_FILE) {
|
||||||
set_message(TTR("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR);
|
set_message(TTR("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
unzClose(pkg);
|
unzClose(pkg);
|
||||||
return "";
|
return "";
|
||||||
|
@ -242,14 +238,12 @@ private:
|
||||||
|
|
||||||
if (!is_folder_empty) {
|
if (!is_folder_empty) {
|
||||||
set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH);
|
set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR);
|
set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR);
|
||||||
memdelete(d);
|
|
||||||
install_path_container->hide();
|
install_path_container->hide();
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
|
@ -257,7 +251,6 @@ private:
|
||||||
|
|
||||||
} else if (valid_path.ends_with("zip")) {
|
} else if (valid_path.ends_with("zip")) {
|
||||||
set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
|
set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -282,7 +275,6 @@ private:
|
||||||
|
|
||||||
if (!is_folder_empty) {
|
if (!is_folder_empty) {
|
||||||
set_message(TTR("The selected path is not empty. Choosing an empty folder is highly recommended."), MESSAGE_WARNING);
|
set_message(TTR("The selected path is not empty. Choosing an empty folder is highly recommended."), MESSAGE_WARNING);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(false);
|
get_ok_button()->set_disabled(false);
|
||||||
return valid_path;
|
return valid_path;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +282,6 @@ private:
|
||||||
|
|
||||||
set_message("");
|
set_message("");
|
||||||
set_message("", MESSAGE_SUCCESS, INSTALL_PATH);
|
set_message("", MESSAGE_SUCCESS, INSTALL_PATH);
|
||||||
memdelete(d);
|
|
||||||
get_ok_button()->set_disabled(false);
|
get_ok_button()->set_disabled(false);
|
||||||
return valid_path;
|
return valid_path;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +380,7 @@ private:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
if (d->change_dir(project_path->get_text()) == OK) {
|
if (d->change_dir(project_path->get_text()) == OK) {
|
||||||
if (!d->dir_exists(project_name_no_edges)) {
|
if (!d->dir_exists(project_name_no_edges)) {
|
||||||
if (d->make_dir(project_name_no_edges) == OK) {
|
if (d->make_dir(project_name_no_edges) == OK) {
|
||||||
|
@ -408,8 +399,6 @@ private:
|
||||||
dialog_error->popup_centered();
|
dialog_error->popup_centered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memdelete(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _text_changed(const String &p_text) {
|
void _text_changed(const String &p_text) {
|
||||||
|
@ -551,14 +540,11 @@ private:
|
||||||
if (path.is_empty() || path == zip_root || !zip_root.is_subsequence_of(path)) {
|
if (path.is_empty() || path == zip_root || !zip_root.is_subsequence_of(path)) {
|
||||||
//
|
//
|
||||||
} else if (path.ends_with("/")) { // a dir
|
} else if (path.ends_with("/")) { // a dir
|
||||||
|
|
||||||
path = path.substr(0, path.length() - 1);
|
path = path.substr(0, path.length() - 1);
|
||||||
String rel_path = path.substr(zip_root.length());
|
String rel_path = path.substr(zip_root.length());
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
da->make_dir(dir.plus_file(rel_path));
|
da->make_dir(dir.plus_file(rel_path));
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Vector<uint8_t> data;
|
Vector<uint8_t> data;
|
||||||
data.resize(info.uncompressed_size);
|
data.resize(info.uncompressed_size);
|
||||||
|
@ -620,9 +606,8 @@ private:
|
||||||
|
|
||||||
void _remove_created_folder() {
|
void _remove_created_folder() {
|
||||||
if (!created_folder_path.is_empty()) {
|
if (!created_folder_path.is_empty()) {
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
d->remove(created_folder_path);
|
d->remove(created_folder_path);
|
||||||
memdelete(d);
|
|
||||||
|
|
||||||
create_dir->set_disabled(false);
|
create_dir->set_disabled(false);
|
||||||
created_folder_path = "";
|
created_folder_path = "";
|
||||||
|
@ -725,10 +710,9 @@ public:
|
||||||
project_path->set_text(fav_dir);
|
project_path->set_text(fav_dir);
|
||||||
fdialog->set_current_dir(fav_dir);
|
fdialog->set_current_dir(fav_dir);
|
||||||
} else {
|
} else {
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
project_path->set_text(d->get_current_dir());
|
project_path->set_text(d->get_current_dir());
|
||||||
fdialog->set_current_dir(d->get_current_dir());
|
fdialog->set_current_dir(d->get_current_dir());
|
||||||
memdelete(d);
|
|
||||||
}
|
}
|
||||||
String proj = TTR("New Game Project");
|
String proj = TTR("New Game Project");
|
||||||
project_name->set_text(proj);
|
project_name->set_text(proj);
|
||||||
|
@ -2411,12 +2395,11 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<String> folders_set;
|
Set<String> folders_set;
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
for (int i = 0; i < p_files.size(); i++) {
|
for (int i = 0; i < p_files.size(); i++) {
|
||||||
String file = p_files[i];
|
String file = p_files[i];
|
||||||
folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir());
|
folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir());
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
if (folders_set.size() > 0) {
|
if (folders_set.size() > 0) {
|
||||||
PackedStringArray folders;
|
PackedStringArray folders;
|
||||||
for (Set<String>::Element *E = folders_set.front(); E; E = E->next()) {
|
for (Set<String>::Element *E = folders_set.front(); E; E = E->next()) {
|
||||||
|
@ -2425,7 +2408,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
|
||||||
|
|
||||||
bool confirm = true;
|
bool confirm = true;
|
||||||
if (folders.size() == 1) {
|
if (folders.size() == 1) {
|
||||||
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
if (dir->change_dir(folders[0]) == OK) {
|
if (dir->change_dir(folders[0]) == OK) {
|
||||||
dir->list_dir_begin();
|
dir->list_dir_begin();
|
||||||
String file = dir->get_next();
|
String file = dir->get_next();
|
||||||
|
@ -2437,7 +2420,6 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
|
||||||
}
|
}
|
||||||
dir->list_dir_end();
|
dir->list_dir_end();
|
||||||
}
|
}
|
||||||
memdelete(dir);
|
|
||||||
}
|
}
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
multi_scan_ask->get_ok_button()->disconnect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders));
|
multi_scan_ask->get_ok_button()->disconnect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders));
|
||||||
|
|
|
@ -247,23 +247,22 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must
|
||||||
return TTR("Path is not local.");
|
return TTR("Path is not local.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
{
|
||||||
if (d->change_dir(p.get_base_dir()) != OK) {
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
memdelete(d);
|
if (da->change_dir(p.get_base_dir()) != OK) {
|
||||||
return TTR("Base path is invalid.");
|
return TTR("Base path is invalid.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memdelete(d);
|
|
||||||
|
|
||||||
// Check if file exists.
|
{
|
||||||
DirAccess *f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
// Check if file exists.
|
||||||
if (f->dir_exists(p)) {
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
memdelete(f);
|
if (da->dir_exists(p)) {
|
||||||
return TTR("A directory with the same name exists.");
|
return TTR("A directory with the same name exists.");
|
||||||
} else if (p_file_must_exist && !f->file_exists(p)) {
|
} else if (p_file_must_exist && !da->file_exists(p)) {
|
||||||
memdelete(f);
|
return TTR("File does not exist.");
|
||||||
return TTR("File does not exist.");
|
}
|
||||||
}
|
}
|
||||||
memdelete(f);
|
|
||||||
|
|
||||||
// Check file extension.
|
// Check file extension.
|
||||||
String extension = p.get_extension();
|
String extension = p.get_extension();
|
||||||
|
@ -556,13 +555,12 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if file exists.
|
// Check if file exists.
|
||||||
DirAccess *f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
String p = ProjectSettings::get_singleton()->localize_path(p_path.strip_edges());
|
String p = ProjectSettings::get_singleton()->localize_path(p_path.strip_edges());
|
||||||
if (f->file_exists(p)) {
|
if (da->file_exists(p)) {
|
||||||
is_new_script_created = false;
|
is_new_script_created = false;
|
||||||
_msg_path_valid(true, TTR("File exists, it will be reused."));
|
_msg_path_valid(true, TTR("File exists, it will be reused."));
|
||||||
}
|
}
|
||||||
memdelete(f);
|
|
||||||
|
|
||||||
is_path_valid = true;
|
is_path_valid = true;
|
||||||
_update_dialog();
|
_update_dialog();
|
||||||
|
@ -838,7 +836,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c
|
||||||
|
|
||||||
String dir_path = p_dir.plus_file(p_object);
|
String dir_path = p_dir.plus_file(p_object);
|
||||||
|
|
||||||
DirAccess *d = DirAccess::open(dir_path);
|
DirAccessRef d = DirAccess::open(dir_path);
|
||||||
if (d) {
|
if (d) {
|
||||||
d->list_dir_begin();
|
d->list_dir_begin();
|
||||||
String file = d->get_next();
|
String file = d->get_next();
|
||||||
|
@ -849,7 +847,6 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c
|
||||||
file = d->get_next();
|
file = d->get_next();
|
||||||
}
|
}
|
||||||
d->list_dir_end();
|
d->list_dir_end();
|
||||||
memdelete(d);
|
|
||||||
}
|
}
|
||||||
return user_templates;
|
return user_templates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2099,9 +2099,8 @@ bool Main::start() {
|
||||||
checked_paths.insert(path);
|
checked_paths.insert(path);
|
||||||
|
|
||||||
// Create the module documentation directory if it doesn't exist
|
// Create the module documentation directory if it doesn't exist
|
||||||
DirAccess *da = DirAccess::create_for_path(path);
|
DirAccessRef da = DirAccess::create_for_path(path);
|
||||||
err = da->make_dir_recursive(path);
|
err = da->make_dir_recursive(path);
|
||||||
memdelete(da);
|
|
||||||
ERR_FAIL_COND_V_MSG(err != OK, false, "Error: Can't create directory: " + path + ": " + itos(err));
|
ERR_FAIL_COND_V_MSG(err != OK, false, "Error: Can't create directory: " + path + ": " + itos(err));
|
||||||
|
|
||||||
print_line("Loading docs from: " + path);
|
print_line("Loading docs from: " + path);
|
||||||
|
@ -2112,9 +2111,8 @@ bool Main::start() {
|
||||||
|
|
||||||
String index_path = doc_tool_path.plus_file("doc/classes");
|
String index_path = doc_tool_path.plus_file("doc/classes");
|
||||||
// Create the main documentation directory if it doesn't exist
|
// Create the main documentation directory if it doesn't exist
|
||||||
DirAccess *da = DirAccess::create_for_path(index_path);
|
DirAccessRef da = DirAccess::create_for_path(index_path);
|
||||||
err = da->make_dir_recursive(index_path);
|
err = da->make_dir_recursive(index_path);
|
||||||
memdelete(da);
|
|
||||||
ERR_FAIL_COND_V_MSG(err != OK, false, "Error: Can't create index directory: " + index_path + ": " + itos(err));
|
ERR_FAIL_COND_V_MSG(err != OK, false, "Error: Can't create index directory: " + index_path + ": " + itos(err));
|
||||||
|
|
||||||
print_line("Loading classes from: " + index_path);
|
print_line("Loading classes from: " + index_path);
|
||||||
|
@ -2452,15 +2450,13 @@ bool Main::start() {
|
||||||
int sep = local_game_path.rfind("/");
|
int sep = local_game_path.rfind("/");
|
||||||
|
|
||||||
if (sep == -1) {
|
if (sep == -1) {
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
local_game_path = da->get_current_dir().plus_file(local_game_path);
|
local_game_path = da->get_current_dir().plus_file(local_game_path);
|
||||||
memdelete(da);
|
|
||||||
} else {
|
} else {
|
||||||
DirAccess *da = DirAccess::open(local_game_path.substr(0, sep));
|
DirAccessRef da = DirAccess::open(local_game_path.substr(0, sep));
|
||||||
if (da) {
|
if (da) {
|
||||||
local_game_path = da->get_current_dir().plus_file(
|
local_game_path = da->get_current_dir().plus_file(
|
||||||
local_game_path.substr(sep + 1, local_game_path.length()));
|
local_game_path.substr(sep + 1, local_game_path.length()));
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,9 +643,8 @@ bool GDMono::copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const
|
||||||
|
|
||||||
// Create destination directory if needed
|
// Create destination directory if needed
|
||||||
if (!DirAccess::exists(dst_dir)) {
|
if (!DirAccess::exists(dst_dir)) {
|
||||||
DirAccess *da = DirAccess::create_for_path(dst_dir);
|
DirAccessRef da = DirAccess::create_for_path(dst_dir);
|
||||||
Error err = da->make_dir_recursive(dst_dir);
|
Error err = da->make_dir_recursive(dst_dir);
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
ERR_PRINT("Failed to create destination directory for the API assemblies. Error: " + itos(err) + ".");
|
ERR_PRINT("Failed to create destination directory for the API assemblies. Error: " + itos(err) + ".");
|
||||||
|
|
|
@ -75,11 +75,10 @@ String _get_android_orientation_label(DisplayServer::ScreenOrientation screen_or
|
||||||
// Utility method used to create a directory.
|
// Utility method used to create a directory.
|
||||||
Error create_directory(const String &p_dir) {
|
Error create_directory(const String &p_dir) {
|
||||||
if (!DirAccess::exists(p_dir)) {
|
if (!DirAccess::exists(p_dir)) {
|
||||||
DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef filesystem_da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create directory '" + p_dir + "'.");
|
ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create directory '" + p_dir + "'.");
|
||||||
Error err = filesystem_da->make_dir_recursive(p_dir);
|
Error err = filesystem_da->make_dir_recursive(p_dir);
|
||||||
ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Cannot create directory '" + p_dir + "'.");
|
ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Cannot create directory '" + p_dir + "'.");
|
||||||
memdelete(filesystem_da);
|
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,7 +530,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
|
||||||
String json_description = "{\"images\":[";
|
String json_description = "{\"images\":[";
|
||||||
String sizes;
|
String sizes;
|
||||||
|
|
||||||
DirAccess *da = DirAccess::open(p_iconset_dir);
|
DirAccessRef da = DirAccess::open(p_iconset_dir);
|
||||||
ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_iconset_dir + "'.");
|
ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_iconset_dir + "'.");
|
||||||
|
|
||||||
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
|
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
|
||||||
|
@ -570,7 +570,6 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
memdelete(da);
|
|
||||||
String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'.");
|
String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'.");
|
||||||
ERR_PRINT(err_str.utf8().get_data());
|
ERR_PRINT(err_str.utf8().get_data());
|
||||||
return err;
|
return err;
|
||||||
|
@ -588,7 +587,6 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
|
||||||
json_description += String("}");
|
json_description += String("}");
|
||||||
}
|
}
|
||||||
json_description += "]}";
|
json_description += "]}";
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
FileAccess *json_file = FileAccess::open(p_iconset_dir + "Contents.json", FileAccess::WRITE);
|
FileAccess *json_file = FileAccess::open(p_iconset_dir + "Contents.json", FileAccess::WRITE);
|
||||||
ERR_FAIL_COND_V(!json_file, ERR_CANT_CREATE);
|
ERR_FAIL_COND_V(!json_file, ERR_CANT_CREATE);
|
||||||
|
@ -674,7 +672,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) {
|
Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) {
|
||||||
DirAccess *da = DirAccess::open(p_dest_dir);
|
DirAccessRef da = DirAccess::open(p_dest_dir);
|
||||||
ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_dest_dir + "'.");
|
ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_dest_dir + "'.");
|
||||||
|
|
||||||
for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
|
for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
|
||||||
|
@ -712,7 +710,6 @@ Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExp
|
||||||
err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
|
err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
memdelete(da);
|
|
||||||
String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path '" + loading_screen_file + "'.";
|
String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path '" + loading_screen_file + "'.";
|
||||||
ERR_PRINT(err_str.utf8().get_data());
|
ERR_PRINT(err_str.utf8().get_data());
|
||||||
return err;
|
return err;
|
||||||
|
@ -760,7 +757,6 @@ Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -966,21 +962,15 @@ void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPrese
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
|
Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
|
||||||
DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
|
||||||
ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
|
|
||||||
|
|
||||||
String binary_name = p_out_dir.get_file().get_basename();
|
String binary_name = p_out_dir.get_file().get_basename();
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create_for_path(p_asset);
|
DirAccessRef da = DirAccess::create_for_path(p_asset);
|
||||||
if (!da) {
|
if (!da) {
|
||||||
memdelete(filesystem_da);
|
|
||||||
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't create directory: " + p_asset + ".");
|
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't create directory: " + p_asset + ".");
|
||||||
}
|
}
|
||||||
bool file_exists = da->file_exists(p_asset);
|
bool file_exists = da->file_exists(p_asset);
|
||||||
bool dir_exists = da->dir_exists(p_asset);
|
bool dir_exists = da->dir_exists(p_asset);
|
||||||
if (!file_exists && !dir_exists) {
|
if (!file_exists && !dir_exists) {
|
||||||
memdelete(da);
|
|
||||||
memdelete(filesystem_da);
|
|
||||||
return ERR_FILE_NOT_FOUND;
|
return ERR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,19 +1030,18 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String
|
||||||
destination = p_out_dir.plus_file(asset_path);
|
destination = p_out_dir.plus_file(asset_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DirAccessRef filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
|
ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
|
||||||
|
|
||||||
if (!filesystem_da->dir_exists(destination_dir)) {
|
if (!filesystem_da->dir_exists(destination_dir)) {
|
||||||
Error make_dir_err = filesystem_da->make_dir_recursive(destination_dir);
|
Error make_dir_err = filesystem_da->make_dir_recursive(destination_dir);
|
||||||
if (make_dir_err) {
|
if (make_dir_err) {
|
||||||
memdelete(da);
|
|
||||||
memdelete(filesystem_da);
|
|
||||||
return make_dir_err;
|
return make_dir_err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error err = dir_exists ? da->copy_dir(p_asset, destination) : da->copy(p_asset, destination);
|
Error err = dir_exists ? da->copy_dir(p_asset, destination) : da->copy(p_asset, destination);
|
||||||
memdelete(da);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
memdelete(filesystem_da);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
IOSExportAsset exported_asset = { binary_name.plus_file(asset_path), p_is_framework, p_should_embed };
|
IOSExportAsset exported_asset = { binary_name.plus_file(asset_path), p_is_framework, p_should_embed };
|
||||||
|
@ -1117,8 +1106,6 @@ Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memdelete(filesystem_da);
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1423,29 +1410,29 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
return ERR_FILE_BAD_PATH;
|
return ERR_FILE_BAD_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
{
|
||||||
if (da) {
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
String current_dir = da->get_current_dir();
|
if (da) {
|
||||||
|
String current_dir = da->get_current_dir();
|
||||||
|
|
||||||
// remove leftovers from last export so they don't interfere
|
// remove leftovers from last export so they don't interfere
|
||||||
// in case some files are no longer needed
|
// in case some files are no longer needed
|
||||||
if (da->change_dir(dest_dir + binary_name + ".xcodeproj") == OK) {
|
if (da->change_dir(dest_dir + binary_name + ".xcodeproj") == OK) {
|
||||||
da->erase_contents_recursive();
|
da->erase_contents_recursive();
|
||||||
}
|
}
|
||||||
if (da->change_dir(dest_dir + binary_name) == OK) {
|
if (da->change_dir(dest_dir + binary_name) == OK) {
|
||||||
da->erase_contents_recursive();
|
da->erase_contents_recursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
da->change_dir(current_dir);
|
da->change_dir(current_dir);
|
||||||
|
|
||||||
if (!da->dir_exists(dest_dir + binary_name)) {
|
if (!da->dir_exists(dest_dir + binary_name)) {
|
||||||
Error err = da->make_dir(dest_dir + binary_name);
|
Error err = da->make_dir(dest_dir + binary_name);
|
||||||
if (err) {
|
if (err) {
|
||||||
memdelete(da);
|
return err;
|
||||||
return err;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep.step("Making .pck", 0)) {
|
if (ep.step("Making .pck", 0)) {
|
||||||
|
@ -1501,7 +1488,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
|
|
||||||
Vector<IOSExportAsset> assets;
|
Vector<IOSExportAsset> assets;
|
||||||
|
|
||||||
DirAccess *tmp_app_path = DirAccess::create_for_path(dest_dir);
|
DirAccessRef tmp_app_path = DirAccess::create_for_path(dest_dir);
|
||||||
ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE);
|
ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE);
|
||||||
|
|
||||||
print_line("Unzipping...");
|
print_line("Unzipping...");
|
||||||
|
@ -1580,7 +1567,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
if (dir_err) {
|
if (dir_err) {
|
||||||
ERR_PRINT("Can't create '" + dir_name + "'.");
|
ERR_PRINT("Can't create '" + dir_name + "'.");
|
||||||
unzClose(src_pkg_zip);
|
unzClose(src_pkg_zip);
|
||||||
memdelete(tmp_app_path);
|
|
||||||
return ERR_CANT_CREATE;
|
return ERR_CANT_CREATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1590,7 +1576,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
if (!f) {
|
if (!f) {
|
||||||
ERR_PRINT("Can't write '" + file + "'.");
|
ERR_PRINT("Can't write '" + file + "'.");
|
||||||
unzClose(src_pkg_zip);
|
unzClose(src_pkg_zip);
|
||||||
memdelete(tmp_app_path);
|
|
||||||
return ERR_CANT_CREATE;
|
return ERR_CANT_CREATE;
|
||||||
};
|
};
|
||||||
f->store_buffer(data.ptr(), data.size());
|
f->store_buffer(data.ptr(), data.size());
|
||||||
|
@ -1613,7 +1598,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
|
|
||||||
if (!found_library) {
|
if (!found_library) {
|
||||||
ERR_PRINT("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive.");
|
ERR_PRINT("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive.");
|
||||||
memdelete(tmp_app_path);
|
|
||||||
return ERR_FILE_NOT_FOUND;
|
return ERR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1671,7 +1655,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path);
|
Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path);
|
||||||
if (lib_copy_err != OK) {
|
if (lib_copy_err != OK) {
|
||||||
ERR_PRINT("Can't copy '" + static_lib_path + "'.");
|
ERR_PRINT("Can't copy '" + static_lib_path + "'.");
|
||||||
memdelete(tmp_app_path);
|
|
||||||
return lib_copy_err;
|
return lib_copy_err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1682,7 +1665,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
if (!tmp_app_path->dir_exists(iconset_dir)) {
|
if (!tmp_app_path->dir_exists(iconset_dir)) {
|
||||||
err = tmp_app_path->make_dir_recursive(iconset_dir);
|
err = tmp_app_path->make_dir_recursive(iconset_dir);
|
||||||
}
|
}
|
||||||
memdelete(tmp_app_path);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1692,43 +1674,43 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_storyboard = p_preset->get("storyboard/use_launch_screen_storyboard");
|
{
|
||||||
|
bool use_storyboard = p_preset->get("storyboard/use_launch_screen_storyboard");
|
||||||
|
|
||||||
String launch_image_path = dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/";
|
String launch_image_path = dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/";
|
||||||
String splash_image_path = dest_dir + binary_name + "/Images.xcassets/SplashImage.imageset/";
|
String splash_image_path = dest_dir + binary_name + "/Images.xcassets/SplashImage.imageset/";
|
||||||
|
|
||||||
DirAccess *launch_screen_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef launch_screen_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
|
|
||||||
if (!launch_screen_da) {
|
if (!launch_screen_da) {
|
||||||
return ERR_CANT_CREATE;
|
return ERR_CANT_CREATE;
|
||||||
}
|
|
||||||
|
|
||||||
if (use_storyboard) {
|
|
||||||
print_line("Using Launch Storyboard");
|
|
||||||
|
|
||||||
if (launch_screen_da->change_dir(launch_image_path) == OK) {
|
|
||||||
launch_screen_da->erase_contents_recursive();
|
|
||||||
launch_screen_da->remove(launch_image_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = _export_loading_screen_file(p_preset, splash_image_path);
|
if (use_storyboard) {
|
||||||
} else {
|
print_line("Using Launch Storyboard");
|
||||||
print_line("Using Launch Images");
|
|
||||||
|
|
||||||
const String launch_screen_path = dest_dir + binary_name + "/Launch Screen.storyboard";
|
if (launch_screen_da->change_dir(launch_image_path) == OK) {
|
||||||
|
launch_screen_da->erase_contents_recursive();
|
||||||
|
launch_screen_da->remove(launch_image_path);
|
||||||
|
}
|
||||||
|
|
||||||
launch_screen_da->remove(launch_screen_path);
|
err = _export_loading_screen_file(p_preset, splash_image_path);
|
||||||
|
} else {
|
||||||
|
print_line("Using Launch Images");
|
||||||
|
|
||||||
if (launch_screen_da->change_dir(splash_image_path) == OK) {
|
const String launch_screen_path = dest_dir + binary_name + "/Launch Screen.storyboard";
|
||||||
launch_screen_da->erase_contents_recursive();
|
|
||||||
launch_screen_da->remove(splash_image_path);
|
launch_screen_da->remove(launch_screen_path);
|
||||||
|
|
||||||
|
if (launch_screen_da->change_dir(splash_image_path) == OK) {
|
||||||
|
launch_screen_da->erase_contents_recursive();
|
||||||
|
launch_screen_da->remove(splash_image_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = _export_loading_screen_images(p_preset, launch_image_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = _export_loading_screen_images(p_preset, launch_image_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memdelete(launch_screen_da);
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1747,15 +1729,17 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
|
|
||||||
#ifdef OSX_ENABLED
|
#ifdef OSX_ENABLED
|
||||||
if (ep.step("Code-signing dylibs", 2)) {
|
{
|
||||||
return ERR_SKIP;
|
if (ep.step("Code-signing dylibs", 2)) {
|
||||||
|
return ERR_SKIP;
|
||||||
|
}
|
||||||
|
DirAccess *dylibs_dir = DirAccess::open(dest_dir + binary_name + "/dylibs");
|
||||||
|
ERR_FAIL_COND_V(!dylibs_dir, ERR_CANT_OPEN);
|
||||||
|
CodesignData codesign_data(p_preset, p_debug);
|
||||||
|
err = _walk_dir_recursive(dylibs_dir, _codesign, &codesign_data);
|
||||||
|
memdelete(dylibs_dir);
|
||||||
|
ERR_FAIL_COND_V(err, err);
|
||||||
}
|
}
|
||||||
DirAccess *dylibs_dir = DirAccess::open(dest_dir + binary_name + "/dylibs");
|
|
||||||
ERR_FAIL_COND_V(!dylibs_dir, ERR_CANT_OPEN);
|
|
||||||
CodesignData codesign_data(p_preset, p_debug);
|
|
||||||
err = _walk_dir_recursive(dylibs_dir, _codesign, &codesign_data);
|
|
||||||
memdelete(dylibs_dir);
|
|
||||||
ERR_FAIL_COND_V(err, err);
|
|
||||||
|
|
||||||
if (ep.step("Making .xcarchive", 3)) {
|
if (ep.step("Making .xcarchive", 3)) {
|
||||||
return ERR_SKIP;
|
return ERR_SKIP;
|
||||||
|
|
|
@ -259,11 +259,9 @@ Error OSIPhone::shell_open(String p_uri) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSIPhone::set_user_data_dir(String p_dir) {
|
void OSIPhone::set_user_data_dir(String p_dir) {
|
||||||
DirAccess *da = DirAccess::open(p_dir);
|
DirAccessRef da = DirAccess::open(p_dir);
|
||||||
|
|
||||||
user_data_dir = da->get_current_dir();
|
user_data_dir = da->get_current_dir();
|
||||||
printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), p_dir.utf8().get_data());
|
printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), p_dir.utf8().get_data());
|
||||||
memdelete(da);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String OSIPhone::get_user_data_dir() const {
|
String OSIPhone::get_user_data_dir() const {
|
||||||
|
|
|
@ -124,7 +124,7 @@ void JavaScriptToolsEditorPlugin::_zip_file(String p_path, String p_base_path, z
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zipFile p_zip) {
|
void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zipFile p_zip) {
|
||||||
DirAccess *dir = DirAccess::open(p_path);
|
DirAccessRef dir = DirAccess::open(p_path);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
WARN_PRINT("Unable to open directory for zipping: " + p_path);
|
WARN_PRINT("Unable to open directory for zipping: " + p_path);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -252,7 +252,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
|
||||||
// Custom offline page
|
// Custom offline page
|
||||||
const String offline_page = p_preset->get("progressive_web_app/offline_page");
|
const String offline_page = p_preset->get("progressive_web_app/offline_page");
|
||||||
if (!offline_page.is_empty()) {
|
if (!offline_page.is_empty()) {
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
const String offline_dest = dir.plus_file(name + ".offline.html");
|
const String offline_dest = dir.plus_file(name + ".offline.html");
|
||||||
err = da->copy(ProjectSettings::get_singleton()->globalize_path(offline_page), offline_dest);
|
err = da->copy(ProjectSettings::get_singleton()->globalize_path(offline_page), offline_dest);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
|
@ -445,18 +445,18 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
|
||||||
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + pck_path);
|
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + pck_path);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
|
||||||
for (int i = 0; i < shared_objects.size(); i++) {
|
{
|
||||||
String dst = base_dir.plus_file(shared_objects[i].path.get_file());
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
error = da->copy(shared_objects[i].path, dst);
|
for (int i = 0; i < shared_objects.size(); i++) {
|
||||||
if (error != OK) {
|
String dst = base_dir.plus_file(shared_objects[i].path.get_file());
|
||||||
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + shared_objects[i].path.get_file());
|
error = da->copy(shared_objects[i].path, dst);
|
||||||
memdelete(da);
|
if (error != OK) {
|
||||||
return error;
|
EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + shared_objects[i].path.get_file());
|
||||||
|
return error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memdelete(da);
|
|
||||||
da = nullptr;
|
|
||||||
|
|
||||||
// Extract templates.
|
// Extract templates.
|
||||||
error = _extract_template(template_path, base_dir, base_name, pwa);
|
error = _extract_template(template_path, base_dir, base_name, pwa);
|
||||||
|
|
|
@ -535,9 +535,8 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
|
||||||
// Issue an error if "mv" failed to move the given resource to the trash can.
|
// Issue an error if "mv" failed to move the given resource to the trash can.
|
||||||
if (err != OK || retval != 0) {
|
if (err != OK || retval != 0) {
|
||||||
ERR_PRINT("move_to_trash: Could not move the resource \"" + path + "\" to the trash can \"" + trash_path + "/files\"");
|
ERR_PRINT("move_to_trash: Could not move the resource \"" + path + "\" to the trash can \"" + trash_path + "/files\"");
|
||||||
DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
err = dir_access->rename(renamed_path, path);
|
err = dir_access->rename(renamed_path, path);
|
||||||
memdelete(dir_access);
|
|
||||||
ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename \"" + renamed_path + "\" back to its original name: \"" + path + "\"");
|
ERR_FAIL_COND_V_MSG(err != OK, err, "Could not rename \"" + renamed_path + "\" back to its original name: \"" + path + "\"");
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
|
||||||
String id;
|
String id;
|
||||||
String main_exe = p_exe_path;
|
String main_exe = p_exe_path;
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
if (!da) {
|
if (!da) {
|
||||||
r_error_msg = TTR("Can't get filesystem access.");
|
r_error_msg = TTR("Can't get filesystem access.");
|
||||||
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
|
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
|
||||||
|
@ -1522,7 +1522,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
|
||||||
}
|
}
|
||||||
|
|
||||||
Error CodeSign::codesign(bool p_use_hardened_runtime, bool p_force, const String &p_path, const String &p_ent_path, String &r_error_msg) {
|
Error CodeSign::codesign(bool p_use_hardened_runtime, bool p_force, const String &p_path, const String &p_ent_path, String &r_error_msg) {
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
if (!da) {
|
if (!da) {
|
||||||
r_error_msg = TTR("Can't get filesystem access.");
|
r_error_msg = TTR("Can't get filesystem access.");
|
||||||
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
|
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "CodeSign: Can't get filesystem access.");
|
||||||
|
|
|
@ -70,7 +70,6 @@ private:
|
||||||
|
|
||||||
Button *makedir;
|
Button *makedir;
|
||||||
Access access = ACCESS_RESOURCES;
|
Access access = ACCESS_RESOURCES;
|
||||||
//Button *action;
|
|
||||||
VBoxContainer *vbox;
|
VBoxContainer *vbox;
|
||||||
FileMode mode;
|
FileMode mode;
|
||||||
LineEdit *dir;
|
LineEdit *dir;
|
||||||
|
|
|
@ -908,10 +908,9 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p
|
||||||
return ERR_CANT_CREATE;
|
return ERR_CANT_CREATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
da->remove(p_path);
|
da->remove(p_path);
|
||||||
da->rename(p_path + ".depren", p_path);
|
da->rename(p_path + ".depren", p_path);
|
||||||
memdelete(da);
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue