mirror of
https://github.com/godotengine/godot
synced 2024-09-04 21:28:28 +00:00
[Unix / DirAccess] Fix removing directory symlinks with remove
, ensure erase_contents_recursive
is not following directory symlinks.
This commit is contained in:
parent
b2f425fe68
commit
57fde36f31
|
@ -84,7 +84,7 @@ static Error _erase_recursive(DirAccess *da) {
|
||||||
String n = da->get_next();
|
String n = da->get_next();
|
||||||
while (!n.is_empty()) {
|
while (!n.is_empty()) {
|
||||||
if (n != "." && n != "..") {
|
if (n != "." && n != "..") {
|
||||||
if (da->current_is_dir()) {
|
if (da->current_is_dir() && !da->is_link(n)) {
|
||||||
dirs.push_back(n);
|
dirs.push_back(n);
|
||||||
} else {
|
} else {
|
||||||
files.push_back(n);
|
files.push_back(n);
|
||||||
|
|
|
@ -419,7 +419,7 @@ Error DirAccessUnix::remove(String p_path) {
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR(flags.st_mode)) {
|
if (S_ISDIR(flags.st_mode) && !is_link(p_path)) {
|
||||||
return ::rmdir(p_path.utf8().get_data()) == 0 ? OK : FAILED;
|
return ::rmdir(p_path.utf8().get_data()) == 0 ? OK : FAILED;
|
||||||
} else {
|
} else {
|
||||||
return ::unlink(p_path.utf8().get_data()) == 0 ? OK : FAILED;
|
return ::unlink(p_path.utf8().get_data()) == 0 ? OK : FAILED;
|
||||||
|
@ -435,7 +435,7 @@ bool DirAccessUnix::is_link(String p_file) {
|
||||||
|
|
||||||
struct stat flags = {};
|
struct stat flags = {};
|
||||||
if ((lstat(p_file.utf8().get_data(), &flags) != 0)) {
|
if ((lstat(p_file.utf8().get_data(), &flags) != 0)) {
|
||||||
return FAILED;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_ISLNK(flags.st_mode);
|
return S_ISLNK(flags.st_mode);
|
||||||
|
|
Loading…
Reference in a new issue