mirror of https://github.com/GNOME/gimp.git
plug-ins/common/tiff-load.c use g_open() to open the file. Should fix
2007-07-29 Sven Neumann <sven@gimp.org> * plug-ins/common/tiff-load.c * plug-ins/common/tiff-save.c: use g_open() to open the file. Should fix filename encoding problems on Win32 (bug #461449). svn path=/trunk/; revision=23061
This commit is contained in:
parent
25a71520b8
commit
5a74a589a1
|
@ -1,3 +1,9 @@
|
|||
2007-07-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/tiff-load.c
|
||||
* plug-ins/common/tiff-save.c: use g_open() to open the file.
|
||||
Should fix filename encoding problems on Win32 (bug #461449).
|
||||
|
||||
2007-07-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/lcms.c: also calculate the checksum when loading
|
||||
|
|
|
@ -47,6 +47,22 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
#ifdef G_OS_WIN32
|
||||
#include <libgimpbase/gimpwin32-io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -260,26 +276,30 @@ run (const gchar *name,
|
|||
|
||||
if (strcmp (name, LOAD_PROC) == 0)
|
||||
{
|
||||
TIFF *tif;
|
||||
const gchar *filename = param[1].data.d_string;
|
||||
TIFF *tif;
|
||||
gint fd;
|
||||
|
||||
gimp_get_data (LOAD_PROC, &target);
|
||||
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
|
||||
|
||||
tif = TIFFOpen (param[1].data.d_string, "r");
|
||||
|
||||
if (! tif)
|
||||
if (fd == -1)
|
||||
{
|
||||
g_message (_("Could not open '%s' for reading: %s"),
|
||||
gimp_filename_to_utf8 (param[1].data.d_string), g_strerror (errno));
|
||||
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
tif = TIFFFdOpen (fd, filename, "r");
|
||||
|
||||
gimp_get_data (LOAD_PROC, &target);
|
||||
|
||||
pages.n_pages = pages.o_pages = TIFFNumberOfDirectories (tif);
|
||||
|
||||
if (pages.n_pages == 0)
|
||||
{
|
||||
g_message (_("TIFF '%s' does not contain any directories"),
|
||||
gimp_filename_to_utf8 (param[1].data.d_string));
|
||||
gimp_filename_to_utf8 (filename));
|
||||
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
@ -331,7 +351,9 @@ run (const gchar *name,
|
|||
else
|
||||
status = GIMP_PDB_CANCEL;
|
||||
}
|
||||
|
||||
TIFFClose (tif);
|
||||
close (fd);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -47,6 +47,22 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
#ifdef G_OS_WIN32
|
||||
#include <libgimpbase/gimpwin32-io.h>
|
||||
#endif
|
||||
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -629,6 +645,7 @@ save_image (const gchar *filename,
|
|||
GimpPixelRgn pixel_rgn;
|
||||
gint tile_height;
|
||||
gint y, yend;
|
||||
gint fd;
|
||||
gboolean is_bw = FALSE;
|
||||
gboolean invert = TRUE;
|
||||
const guchar bw_map[] = { 0, 0, 0, 255, 255, 255 };
|
||||
|
@ -647,14 +664,17 @@ save_image (const gchar *filename,
|
|||
tile_height = gimp_tile_height ();
|
||||
rowsperstrip = tile_height;
|
||||
|
||||
tif = TIFFOpen (filename, "w");
|
||||
if (! tif)
|
||||
fd = g_open (filename, O_CREAT | O_TRUNC | O_WRONLY | _O_BINARY, 0644);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
g_message (_("Could not open '%s' for writing: %s"),
|
||||
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen (fd, filename, "w");
|
||||
|
||||
TIFFSetWarningHandler (tiff_warning);
|
||||
TIFFSetErrorHandler (tiff_error);
|
||||
|
||||
|
@ -999,6 +1019,7 @@ save_image (const gchar *filename,
|
|||
|
||||
TIFFFlushData (tif);
|
||||
TIFFClose (tif);
|
||||
close (fd);
|
||||
|
||||
gimp_progress_update (1.0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue