[glib: 1/3] gfileutils: Ignore ENOENT from all except the last element



commit 6f55306e04e51e2e9021a5fe29288e415a10a868
Author: Robert Nagy <robert openbsd org>
Date:   Mon May 13 18:38:22 2019 +0200

    gfileutils: Ignore ENOENT from all except the last element
    
    Ignore ENOENT errors up until the last element while trying to create each
    of the path elements in case a restricted file-system is being used where
    path elements can be hidden or non-accessible.

 glib/gfileutils.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 676c08c21..8bff0e9c5 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -248,9 +248,12 @@ g_mkdir_with_parents (const gchar *pathname,
          if (g_mkdir (fn, mode) == -1 && errno != EEXIST)
            {
              int errno_save = errno;
-             g_free (fn);
-             errno = errno_save;
-             return -1;
+              if (p && errno != ENOENT)
+                {
+                 g_free (fn);
+                 errno = errno_save;
+                 return -1;
+               }
            }
        }
       else if (!g_file_test (fn, G_FILE_TEST_IS_DIR))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]