|
@@ -334,7 +334,7 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags) {
|
|
|
+Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags, bool p_copy_links) {
|
|
|
List<String> dirs;
|
|
|
|
|
|
String curdir = get_current_dir();
|
|
@@ -342,7 +342,9 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
|
|
|
String n = get_next();
|
|
|
while (n != String()) {
|
|
|
if (n != "." && n != "..") {
|
|
|
- if (current_is_dir()) {
|
|
|
+ if (p_copy_links && is_link(get_current_dir().plus_file(n))) {
|
|
|
+ create_link(read_link(get_current_dir().plus_file(n)), p_to + n);
|
|
|
+ } else if (current_is_dir()) {
|
|
|
dirs.push_back(n);
|
|
|
} else {
|
|
|
const String &rel_path = n;
|
|
@@ -374,7 +376,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
|
|
|
Error err = change_dir(E->get());
|
|
|
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'.");
|
|
|
|
|
|
- err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags);
|
|
|
+ err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links);
|
|
|
if (err) {
|
|
|
change_dir("..");
|
|
|
ERR_FAIL_V_MSG(err, "Failed to copy recursively.");
|
|
@@ -386,7 +388,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
|
|
|
return OK;
|
|
|
}
|
|
|
|
|
|
-Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
|
|
|
+Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_copy_links) {
|
|
|
ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist.");
|
|
|
|
|
|
DirAccess *target_da = DirAccess::create_for_path(p_to);
|
|
@@ -405,7 +407,7 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
|
|
|
}
|
|
|
|
|
|
DirChanger dir_changer(this, p_from);
|
|
|
- Error err = _copy_dir(target_da, p_to, p_chmod_flags);
|
|
|
+ Error err = _copy_dir(target_da, p_to, p_chmod_flags, p_copy_links);
|
|
|
memdelete(target_da);
|
|
|
|
|
|
return err;
|