mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-24 09:58:54 +02:00
Merge branch 'rnagy/glib-mkdir' into 'master'
Resubmission of !832 “Try to create the complete path right away and fall back” See merge request GNOME/glib!1007
This commit is contained in:
@@ -226,6 +226,20 @@ g_mkdir_with_parents (const gchar *pathname,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* try to create the full path first */
|
||||||
|
if (g_mkdir (pathname, mode) == 0)
|
||||||
|
return 0;
|
||||||
|
else if (errno == EEXIST)
|
||||||
|
{
|
||||||
|
if (!g_file_test (pathname, G_FILE_TEST_IS_DIR))
|
||||||
|
{
|
||||||
|
errno = ENOTDIR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* walk the full path and try creating each element */
|
||||||
fn = g_strdup (pathname);
|
fn = g_strdup (pathname);
|
||||||
|
|
||||||
if (g_path_is_absolute (fn))
|
if (g_path_is_absolute (fn))
|
||||||
@@ -248,9 +262,12 @@ g_mkdir_with_parents (const gchar *pathname,
|
|||||||
if (g_mkdir (fn, mode) == -1 && errno != EEXIST)
|
if (g_mkdir (fn, mode) == -1 && errno != EEXIST)
|
||||||
{
|
{
|
||||||
int errno_save = errno;
|
int errno_save = errno;
|
||||||
g_free (fn);
|
if (p && errno != ENOENT)
|
||||||
errno = errno_save;
|
{
|
||||||
return -1;
|
g_free (fn);
|
||||||
|
errno = errno_save;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!g_file_test (fn, G_FILE_TEST_IS_DIR))
|
else if (!g_file_test (fn, G_FILE_TEST_IS_DIR))
|
||||||
|
Reference in New Issue
Block a user