plug-ins: various g_file_get_path() replaced by g_file_peek_path().
As explained in previous commits, the _peek_ call is advantageous because: - It is less bug-prone as we don't have to handle freeing the string. In all the cases I changed, I even spotted at least 2 cases where we were leaking a string (in file-mng, `temp_file_name` is never freed; and we were also leaking in an error case of gfig). - As a consequence of the previous point: simpler code with less lines. - In local file cases, the _peek_ variant does not even need to allocate an additional string. - In other case, if we query several times the path, it is allocated once and cached so it stays efficient. - When possible, working on the GFile rather than on a path string may be more robust. For instance I changed one g_unlink() into a g_file_delete(). Actually most reading/writing should be done with the GIO API when possible, but I didn't want to change too much code logics on this commit.
This commit is contained in:
parent
2ddc2ab7be
commit
27dea4f7f7
15 changed files with 45 additions and 167 deletions
|
|
@ -193,9 +193,7 @@ load_image (GFile *file,
|
|||
GimpRunMode runmode,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename = g_file_get_path (file);
|
||||
|
||||
FILE *inputFile = g_fopen (filename, "rb");
|
||||
FILE *inputFile = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
gsize inputFileSize;
|
||||
gpointer memory;
|
||||
|
|
@ -220,8 +218,8 @@ load_image (GFile *file,
|
|||
if (!inputFile)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"Cannot open file for read: %s\n", filename);
|
||||
g_free (filename);
|
||||
"Cannot open file for read: %s\n",
|
||||
g_file_peek_path (file));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -232,9 +230,9 @@ load_image (GFile *file,
|
|||
if (inputFileSize < 1)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"File too small: %s\n", filename);
|
||||
"File too small: %s\n",
|
||||
g_file_peek_path (file));
|
||||
fclose (inputFile);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -242,11 +240,10 @@ load_image (GFile *file,
|
|||
if (fread (memory, 1, inputFileSize, inputFile) != inputFileSize)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"Failed to read %zu bytes: %s\n", inputFileSize, filename);
|
||||
"Failed to read %zu bytes: %s\n", inputFileSize,
|
||||
g_file_peek_path (file));
|
||||
fclose (inputFile);
|
||||
g_free (memory);
|
||||
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -256,9 +253,9 @@ load_image (GFile *file,
|
|||
if (signature != JXL_SIG_CODESTREAM && signature != JXL_SIG_CONTAINER)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"File %s is probably not in JXL format!\n", filename);
|
||||
"File %s is probably not in JXL format!\n",
|
||||
g_file_peek_path (file));
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +265,6 @@ load_image (GFile *file,
|
|||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"ERROR: JxlDecoderCreate failed");
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +276,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +286,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +296,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +307,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +317,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +328,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -348,7 +338,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +349,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -506,7 +494,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -522,7 +509,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -539,7 +525,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -600,7 +585,6 @@ load_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlDecoderDestroy (decoder);
|
||||
g_free (memory);
|
||||
g_free (filename);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
|
@ -665,7 +649,6 @@ save_image (GFile *file,
|
|||
|
||||
GByteArray *compressed;
|
||||
|
||||
gchar *filename;
|
||||
FILE *outfile;
|
||||
GeglBuffer *buffer;
|
||||
GimpImageType drawable_type;
|
||||
|
|
@ -688,8 +671,7 @@ save_image (GFile *file,
|
|||
gint speed = 7;
|
||||
gboolean uses_original_profile = FALSE;
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
gimp_progress_init_printf ("Exporting '%s'.", filename);
|
||||
gimp_progress_init_printf ("Exporting '%s'.", g_file_peek_path (file));
|
||||
|
||||
g_object_get (config,
|
||||
"lossless", &lossless,
|
||||
|
|
@ -719,7 +701,6 @@ save_image (GFile *file,
|
|||
{
|
||||
g_printerr ("%s: error getting the profile space: %s\n",
|
||||
G_STRFUNC, (*error)->message);
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -801,7 +782,6 @@ save_image (GFile *file,
|
|||
{
|
||||
g_object_unref (profile);
|
||||
}
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
@ -832,7 +812,6 @@ save_image (GFile *file,
|
|||
{
|
||||
g_object_unref (profile);
|
||||
}
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -848,7 +827,6 @@ save_image (GFile *file,
|
|||
{
|
||||
g_object_unref (profile);
|
||||
}
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -864,7 +842,6 @@ save_image (GFile *file,
|
|||
{
|
||||
g_object_unref (profile);
|
||||
}
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -885,7 +862,6 @@ save_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlEncoderDestroy (encoder);
|
||||
g_free (picture_buffer);
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -905,7 +881,6 @@ save_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlEncoderDestroy (encoder);
|
||||
g_free (picture_buffer);
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -939,7 +914,6 @@ save_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlEncoderDestroy (encoder);
|
||||
g_free (picture_buffer);
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -967,7 +941,6 @@ save_image (GFile *file,
|
|||
JxlThreadParallelRunnerDestroy (runner);
|
||||
JxlEncoderDestroy (encoder);
|
||||
g_free (picture_buffer);
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -984,17 +957,16 @@ save_image (GFile *file,
|
|||
|
||||
if (compressed->len > 0)
|
||||
{
|
||||
outfile = g_fopen (filename, "wb");
|
||||
outfile = g_fopen (g_file_peek_path (file), "wb");
|
||||
if (!outfile)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"Could not open '%s' for writing!\n", filename);
|
||||
g_free (filename);
|
||||
"Could not open '%s' for writing!\n",
|
||||
g_file_peek_path (file));
|
||||
g_byte_array_free (compressed, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
fwrite (compressed->data, 1, compressed->len, outfile);
|
||||
fclose (outfile);
|
||||
|
||||
|
|
@ -1007,7 +979,6 @@ save_image (GFile *file,
|
|||
g_set_error (error, G_FILE_ERROR, 0,
|
||||
"No data to write");
|
||||
g_byte_array_free (compressed, TRUE);
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -781,7 +781,6 @@ mng_save_image (GFile *file,
|
|||
GObject *config,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
gboolean ret = FALSE;
|
||||
gint rows, cols;
|
||||
volatile gint i;
|
||||
|
|
@ -865,12 +864,8 @@ mng_save_image (GFile *file,
|
|||
}
|
||||
}
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
|
||||
userdata = g_new0 (struct mnglib_userdata_t, 1);
|
||||
userdata->fp = g_fopen (filename, "wb");
|
||||
|
||||
g_free (filename);
|
||||
userdata->fp = g_fopen (g_file_peek_path (file), "wb");
|
||||
|
||||
if (! userdata->fp)
|
||||
{
|
||||
|
|
@ -1064,7 +1059,6 @@ mng_save_image (GFile *file,
|
|||
gchar frame_mode;
|
||||
int frame_delay;
|
||||
GFile *temp_file;
|
||||
gchar *temp_file_name;
|
||||
png_structp pp;
|
||||
png_infop info;
|
||||
FILE *infile, *outfile;
|
||||
|
|
@ -1220,9 +1214,7 @@ mng_save_image (GFile *file,
|
|||
goto err3;
|
||||
}
|
||||
|
||||
temp_file_name = g_file_get_path (temp_file);
|
||||
|
||||
if ((outfile = g_fopen (temp_file_name, "wb")) == NULL)
|
||||
if ((outfile = g_fopen (g_file_peek_path (temp_file), "wb")) == NULL)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Could not open '%s' for writing: %s"),
|
||||
|
|
@ -1404,7 +1396,7 @@ mng_save_image (GFile *file,
|
|||
|
||||
fclose (outfile);
|
||||
|
||||
infile = g_fopen (temp_file_name, "rb");
|
||||
infile = g_fopen (g_file_peek_path (temp_file), "rb");
|
||||
|
||||
if (! infile)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -597,7 +597,6 @@ load_image (GFile *file,
|
|||
GimpPrecision image_precision; /* Precision of image */
|
||||
GimpImageType layer_type; /* Type of drawable/layer */
|
||||
GimpColorProfile *profile = NULL; /* Color profile */
|
||||
gchar *filename;
|
||||
gchar *profile_name = NULL; /* Profile's name */
|
||||
gboolean linear = FALSE; /* Linear RGB */
|
||||
FILE *fp; /* File pointer */
|
||||
|
|
@ -659,9 +658,7 @@ load_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
|
|
@ -1311,7 +1308,6 @@ save_image (GFile *file,
|
|||
GimpColorProfile *profile = NULL; /* Color profile */
|
||||
gboolean out_linear; /* Save linear RGB */
|
||||
GeglBuffer *buffer; /* GEGL buffer for layer */
|
||||
gchar *filename;
|
||||
const Babl *file_format = NULL; /* BABL format of file */
|
||||
const gchar *encoding;
|
||||
const Babl *space;
|
||||
|
|
@ -1499,9 +1495,7 @@ save_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Exporting '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "wb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "wb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -330,7 +330,6 @@ static gboolean
|
|||
load_wmf_size (GFile *file,
|
||||
WmfLoadVals *vals)
|
||||
{
|
||||
gchar *filename;
|
||||
GMappedFile *mapped;
|
||||
/* the bits we need to decode the WMF via libwmf2's GD layer */
|
||||
wmf_error_t err;
|
||||
|
|
@ -344,9 +343,7 @@ load_wmf_size (GFile *file,
|
|||
gboolean success = TRUE;
|
||||
char* wmffontdirs[2] = { NULL, NULL };
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
mapped = g_mapped_file_new (filename, FALSE, NULL);
|
||||
g_free (filename);
|
||||
mapped = g_mapped_file_new (g_file_peek_path (file), FALSE, NULL);
|
||||
|
||||
if (! mapped)
|
||||
return FALSE;
|
||||
|
|
@ -798,7 +795,6 @@ wmf_get_pixbuf (GFile *file,
|
|||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
gchar *filename;
|
||||
GMappedFile *mapped;
|
||||
guchar *pixels = NULL;
|
||||
|
||||
|
|
@ -814,9 +810,7 @@ wmf_get_pixbuf (GFile *file,
|
|||
gint *gd_pixels = NULL;
|
||||
char* wmffontdirs[2] = { NULL, NULL };
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
mapped = g_mapped_file_new (filename, FALSE, NULL);
|
||||
g_free (filename);
|
||||
mapped = g_mapped_file_new (g_file_peek_path (file), FALSE, NULL);
|
||||
|
||||
if (! mapped)
|
||||
return NULL;
|
||||
|
|
@ -921,7 +915,6 @@ wmf_load_file (GFile *file,
|
|||
guint *height,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
GMappedFile *mapped;
|
||||
guchar *pixels = NULL;
|
||||
|
||||
|
|
@ -937,9 +930,7 @@ wmf_load_file (GFile *file,
|
|||
|
||||
*width = *height = -1;
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
mapped = g_mapped_file_new (filename, FALSE, NULL);
|
||||
g_free (filename);
|
||||
mapped = g_mapped_file_new (g_file_peek_path (file), FALSE, NULL);
|
||||
|
||||
if (! mapped)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -631,7 +631,6 @@ static GimpImage *
|
|||
load_image (GFile *file,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
|
|
@ -652,9 +651,7 @@ load_image (GFile *file,
|
|||
|
||||
/* Open the file and check it is a valid X cursor */
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
|
|
@ -876,7 +873,6 @@ load_thumbnail (GFile *file,
|
|||
guint32 diff; /* difference between thumb_size and current size */
|
||||
guint32 min_diff = XCURSOR_IMAGE_MAX_SIZE; /* minimum value of diff */
|
||||
guint32 type; /* chunk type */
|
||||
gchar *filename;
|
||||
FILE *fp = NULL;
|
||||
GimpImage *image = NULL;
|
||||
GimpLayer *layer;
|
||||
|
|
@ -896,9 +892,7 @@ load_thumbnail (GFile *file,
|
|||
*thumb_height = 0;
|
||||
*thumb_num_layers = 0;
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
@ -1330,7 +1324,6 @@ save_image (GFile *file,
|
|||
GObject *config,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp; /* File pointer */
|
||||
gboolean dimension_warn = FALSE; /* become TRUE if even one
|
||||
* of the dimensions of the
|
||||
|
|
@ -1385,9 +1378,7 @@ save_image (GFile *file,
|
|||
*/
|
||||
DM_XMC ("Open the file pointer.\n");
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "wb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "wb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -375,7 +375,6 @@ static GimpImage *
|
|||
load_image (GFile *file,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
XpmImage xpm_image;
|
||||
guchar *cmap;
|
||||
GimpImage *image;
|
||||
|
|
@ -383,10 +382,8 @@ load_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
|
||||
/* read the raw file */
|
||||
switch (XpmReadFileToXpmImage (filename, &xpm_image, NULL))
|
||||
switch (XpmReadFileToXpmImage (g_file_peek_path (file), &xpm_image, NULL))
|
||||
{
|
||||
case XpmSuccess:
|
||||
break;
|
||||
|
|
@ -395,22 +392,17 @@ load_image (GFile *file,
|
|||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("Error opening file '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
|
||||
case XpmFileInvalid:
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
"%s", _("XPM file invalid"));
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
|
||||
default:
|
||||
g_free (filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
|
||||
cmap = parse_colors (&xpm_image);
|
||||
|
||||
image = gimp_image_new (xpm_image.width,
|
||||
|
|
@ -649,7 +641,6 @@ save_image (GFile *file,
|
|||
gboolean alpha;
|
||||
gboolean alpha_used = FALSE;
|
||||
XpmColor *colormap;
|
||||
gchar *filename;
|
||||
XpmImage *xpm_image;
|
||||
guint *ibuff = NULL;
|
||||
guchar *buf;
|
||||
|
|
@ -847,10 +838,8 @@ save_image (GFile *file,
|
|||
xpm_image->colorTable = colormap;
|
||||
xpm_image->data = ibuff;
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
|
||||
/* do the save */
|
||||
switch (XpmWriteFileFromXpmImage (filename, xpm_image, NULL))
|
||||
switch (XpmWriteFileFromXpmImage (g_file_peek_path (file), xpm_image, NULL))
|
||||
{
|
||||
case XpmSuccess:
|
||||
success = TRUE;
|
||||
|
|
@ -871,8 +860,6 @@ save_image (GFile *file,
|
|||
break;
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
|
||||
g_object_unref (buffer);
|
||||
g_free (ibuff);
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ load_image (GFile *file,
|
|||
gboolean interactive,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
EXRLoader *loader;
|
||||
gint width;
|
||||
gint height;
|
||||
|
|
@ -188,9 +187,7 @@ load_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
loader = exr_loader_new (filename);
|
||||
g_free (filename);
|
||||
loader = exr_loader_new (g_file_peek_path (file));
|
||||
|
||||
if (! loader)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -222,7 +222,6 @@ load_image (GFile *file,
|
|||
int hibit;
|
||||
struct g3_tree *p;
|
||||
int nr_pels;
|
||||
gchar *filename;
|
||||
int fd;
|
||||
int color;
|
||||
int i, rr, rsize;
|
||||
|
|
@ -248,9 +247,7 @@ load_image (GFile *file,
|
|||
|
||||
init_byte_tab (0, byte_tab);
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
|
||||
g_free (filename);
|
||||
fd = g_open (g_file_peek_path (file), O_RDONLY | _O_BINARY, 0);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -364,7 +364,6 @@ load_image (GFile *file,
|
|||
guint picnum;
|
||||
gint k, n_images, max_images, hdu_picnum;
|
||||
gint compose;
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
FitsFile *ifp;
|
||||
FitsHduList *hdu;
|
||||
|
|
@ -374,9 +373,7 @@ load_image (GFile *file,
|
|||
"compose", &compose_arg,
|
||||
NULL);
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
@ -388,9 +385,7 @@ load_image (GFile *file,
|
|||
|
||||
fclose (fp);
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
ifp = fits_open (filename, "r");
|
||||
g_free (filename);
|
||||
ifp = fits_open (g_file_peek_path (file), "r");
|
||||
|
||||
if (! ifp)
|
||||
{
|
||||
|
|
@ -479,7 +474,6 @@ save_image (GFile *file,
|
|||
GimpDrawable *drawable,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FitsFile *ofp;
|
||||
GimpImageType drawable_type;
|
||||
gint retval;
|
||||
|
|
@ -511,9 +505,7 @@ save_image (GFile *file,
|
|||
gimp_file_get_utf8_name (file));
|
||||
|
||||
/* Open the output file. */
|
||||
filename = g_file_get_path (file);
|
||||
ofp = fits_open (filename, "w");
|
||||
g_free (filename);
|
||||
ofp = fits_open (g_file_peek_path (file), "w");
|
||||
|
||||
if (! ofp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -444,15 +444,12 @@ get_info (GFile *file,
|
|||
gint32 *frames,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
s_fli_header fli_header;
|
||||
|
||||
*width = 0; *height = 0; *frames = 0;
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename ,"rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file),"rb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
@ -480,7 +477,6 @@ load_image (GFile *file,
|
|||
GObject *config,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
GeglBuffer *buffer;
|
||||
GimpImage *image;
|
||||
|
|
@ -500,9 +496,7 @@ load_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename ,"rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file) ,"rb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
@ -641,7 +635,6 @@ save_image (GFile *file,
|
|||
GObject *config,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
GList *framelist;
|
||||
GList *iter;
|
||||
|
|
@ -776,9 +769,7 @@ save_image (GFile *file,
|
|||
fli_header.aspect_y = 1; /* ... as GIMP supports it. */
|
||||
fli_header.oframe1 = fli_header.oframe2 = 0; /* will be fixed during the write */
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename , "wb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file) , "wb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -653,7 +653,6 @@ GimpImage *
|
|||
ico_load_image (GFile *file,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
IcoLoadInfo *info;
|
||||
gint max_width, max_height;
|
||||
|
|
@ -666,9 +665,7 @@ ico_load_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
@ -734,7 +731,6 @@ ico_load_thumbnail_image (GFile *file,
|
|||
gint *height,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename;
|
||||
FILE *fp;
|
||||
IcoLoadInfo *info;
|
||||
GimpImage *image;
|
||||
|
|
@ -748,9 +744,7 @@ ico_load_thumbnail_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
fp = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
fp = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -314,7 +314,6 @@ load_image (GFile *file,
|
|||
tile_height, /* Height of tile in GIMP */
|
||||
count, /* Count of rows to put in image */
|
||||
bytes; /* Number of channels to use */
|
||||
gchar *filename;
|
||||
sgi_t *sgip; /* File pointer */
|
||||
GimpImage *image; /* Image */
|
||||
GimpLayer *layer; /* Layer */
|
||||
|
|
@ -332,9 +331,7 @@ load_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
sgip = sgiOpen (filename, SGI_READ, 0, 0, 0, 0, 0);
|
||||
g_free (filename);
|
||||
sgip = sgiOpen (g_file_peek_path (file), SGI_READ, 0, 0, 0, 0, 0);
|
||||
|
||||
if (! sgip)
|
||||
{
|
||||
|
|
@ -593,7 +590,6 @@ save_image (GFile *file,
|
|||
gint tile_height; /* Height of tile in GIMP */
|
||||
gint count; /* Count of rows to put in image */
|
||||
gint zsize; /* Number of channels in file */
|
||||
gchar *filename;
|
||||
sgi_t *sgip; /* File pointer */
|
||||
GeglBuffer *buffer; /* Buffer for layer */
|
||||
const Babl *format;
|
||||
|
|
@ -649,10 +645,8 @@ save_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Exporting '%s'"),
|
||||
gimp_file_get_utf8_name (file));
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
sgip = sgiOpen (filename, SGI_WRITE, compression, 1,
|
||||
sgip = sgiOpen (g_file_peek_path (file), SGI_WRITE, compression, 1,
|
||||
width, height, zsize);
|
||||
g_free (filename);
|
||||
|
||||
if (! sgip)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -793,7 +793,6 @@ GFigObj *
|
|||
gfig_load_from_parasite (void)
|
||||
{
|
||||
GFile *file;
|
||||
gchar *fname;
|
||||
FILE *fp;
|
||||
GimpParasite *parasite;
|
||||
const gchar *parasite_data;
|
||||
|
|
@ -806,9 +805,8 @@ gfig_load_from_parasite (void)
|
|||
return NULL;
|
||||
|
||||
file = gimp_temp_file ("gfigtmp");
|
||||
fname = g_file_get_path (file);
|
||||
|
||||
fp = g_fopen (fname, "wb");
|
||||
fp = g_fopen (g_file_peek_path (file), "wb");
|
||||
if (! fp)
|
||||
{
|
||||
g_message (_("Error trying to open temporary file '%s' "
|
||||
|
|
@ -823,11 +821,10 @@ gfig_load_from_parasite (void)
|
|||
|
||||
gimp_parasite_free (parasite);
|
||||
|
||||
gfig = gfig_load (fname, "(none)");
|
||||
gfig = gfig_load (g_file_peek_path (file), "(none)");
|
||||
|
||||
g_unlink (fname);
|
||||
g_file_delete (file, NULL, NULL);
|
||||
|
||||
g_free (fname);
|
||||
g_object_unref (file);
|
||||
|
||||
return gfig;
|
||||
|
|
|
|||
|
|
@ -170,13 +170,10 @@ preferences_load(PreferencesData_t *data)
|
|||
FILE *in;
|
||||
char buf[256];
|
||||
GFile *file;
|
||||
gchar *filename;
|
||||
|
||||
file = gimp_directory_file ("imagemaprc", NULL);
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
in = g_fopen (filename, "rb");
|
||||
g_free (filename);
|
||||
in = g_fopen (g_file_peek_path (file), "rb");
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
|
|
@ -203,14 +200,11 @@ preferences_save(PreferencesData_t *data)
|
|||
{
|
||||
FILE *out;
|
||||
GFile *file;
|
||||
gchar *filename;
|
||||
ColorSelData_t *colors = &data->colors;
|
||||
|
||||
file = gimp_directory_file ("imagemaprc", NULL);
|
||||
|
||||
filename = g_file_get_path (file);
|
||||
out = g_fopen(filename, "wb");
|
||||
g_free (filename);
|
||||
out = g_fopen(g_file_peek_path (file), "wb");
|
||||
|
||||
if (out)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ screenshot_osx_shoot (ScreenshotValues *shootvals,
|
|||
const gchar *mode = " ";
|
||||
const gchar *cursor = " ";
|
||||
gchar *delay = NULL;
|
||||
gchar *filename;
|
||||
GFile *tmpfile;
|
||||
gchar *quoted;
|
||||
gchar *command = NULL;
|
||||
|
|
@ -121,9 +120,8 @@ screenshot_osx_shoot (ScreenshotValues *shootvals,
|
|||
|
||||
delay = g_strdup_printf ("-T %i", shootvals->screenshot_delay);
|
||||
|
||||
tmpfile = gimp_temp_file ("png");
|
||||
filename = g_file_get_path (tmpfile);
|
||||
quoted = g_shell_quote (filename);
|
||||
tmpfile = gimp_temp_file ("png");
|
||||
quoted = g_shell_quote (g_file_peek_path (tmpfile));
|
||||
|
||||
command = g_strjoin (" ",
|
||||
"/usr/sbin/screencapture",
|
||||
|
|
@ -146,14 +144,12 @@ screenshot_osx_shoot (ScreenshotValues *shootvals,
|
|||
gimp_image_set_file (*image, g_file_new_for_uri ("screenshot.png"));
|
||||
|
||||
g_file_delete (tmpfile, NULL, NULL);
|
||||
g_free (filename);
|
||||
g_free (command);
|
||||
|
||||
return GIMP_PDB_SUCCESS;
|
||||
}
|
||||
|
||||
g_free (command);
|
||||
g_free (filename);
|
||||
|
||||
return GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue