libgimpconfig: create parent directories for config file if necessary.

The directory should be already created by GIMP. But just in case it is
not there, for whatever reason, don't just fail. Try and create all
parents.
This commit is contained in:
Jehan 2018-04-22 22:11:13 +02:00
parent ada987828d
commit 08cc37271f
1 changed files with 15 additions and 0 deletions

View File

@ -170,10 +170,25 @@ gimp_config_writer_new_gfile (GFile *file,
{
GimpConfigWriter *writer;
GOutputStream *output;
GFile *dir;
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
dir = g_file_get_parent (file);
if (dir && ! g_file_query_exists (dir, NULL))
{
if (! g_file_make_directory_with_parents (dir, NULL, error))
g_prefix_error (error,
_("Could not create directory '%s' for '%s': "),
gimp_file_get_utf8_name (dir),
gimp_file_get_utf8_name (file));
}
g_object_unref (dir);
if (error && *error)
return NULL;
if (atomic)
{
output = G_OUTPUT_STREAM (g_file_replace (file,