[libgsystem] shutil: rm_rf should delete symlinks to directories, not follow them
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] shutil: rm_rf should delete symlinks to directories, not follow them
- Date: Fri, 1 Mar 2013 21:04:02 +0000 (UTC)
commit 5166164a282bcd77997f94962acf66be2d302aae
Author: Colin Walters <walters verbum org>
Date: Fri Mar 1 16:03:25 2013 -0500
shutil: rm_rf should delete symlinks to directories, not follow them
Like coreutils does.
gsystem-shutil.c | 35 +++++++++++++++++++++++++++--------
1 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/gsystem-shutil.c b/gsystem-shutil.c
index dc62741..4070ba4 100644
--- a/gsystem-shutil.c
+++ b/gsystem-shutil.c
@@ -213,6 +213,31 @@ gs_shutil_rm_rf (GFile *path,
GFileInfo *file_info = NULL;
GError *temp_error = NULL;
+ if (!gs_file_unlink (path, cancellable, &temp_error))
+ {
+ if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ g_clear_error (&temp_error);
+ ret = TRUE;
+ goto out;
+ }
+ else if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY))
+ {
+ g_clear_error (&temp_error);
+ /* Fall through */
+ }
+ else
+ {
+ g_propagate_error (error, temp_error);
+ goto out;
+ }
+ }
+ else
+ {
+ ret = TRUE;
+ goto out;
+ }
+
dir_enum = g_file_enumerate_children (path, "standard::type,standard::name",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable, &temp_error);
@@ -223,16 +248,10 @@ gs_shutil_rm_rf (GFile *path,
g_clear_error (&temp_error);
ret = TRUE;
}
- else if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY))
+ else
{
- g_clear_error (&temp_error);
- if (!gs_file_unlink (path, cancellable, error))
- goto out;
- ret = TRUE;
+ g_propagate_error (error, temp_error);
}
- else
- g_propagate_error (error, temp_error);
-
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]