Commit 648cccde authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/base/base.c app/base/temp-buf.c app/base/tile-swap.c

2005-02-07  Sven Neumann  <sven@gimp.org>

	* app/base/base.c
	* app/base/temp-buf.c
	* app/base/tile-swap.c
	* app/config/gimpconfig-file.c
	* app/core/gimpbrush.c
	* app/core/gimpbrushgenerated.c
	* app/core/gimpbrushpipe.c
	* app/core/gimpdata.c
	* app/core/gimpenvirontable.c
	* app/core/gimpgradient-load.c
	* app/core/gimpgradient-save.c
	* app/core/gimppalette-import.c
	* app/core/gimppalette.c
	* app/core/gimppattern.c
	* app/dialogs/user-install-dialog.c
	* app/gui/session.c
	* app/menus/menus.c
	* app/widgets/gimpdevices.c: use gstdio wrappers.
parent e6285abf
2005-02-07 Sven Neumann <sven@gimp.org>
* app/base/base.c
* app/base/temp-buf.c
* app/base/tile-swap.c
* app/config/gimpconfig-file.c
* app/core/gimpbrush.c
* app/core/gimpbrushgenerated.c
* app/core/gimpbrushpipe.c
* app/core/gimpdata.c
* app/core/gimpenvirontable.c
* app/core/gimpgradient-load.c
* app/core/gimpgradient-save.c
* app/core/gimppalette-import.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/dialogs/user-install-dialog.c
* app/gui/session.c
* app/menus/menus.c
* app/widgets/gimpdevices.c: use gstdio wrappers.
2005-02-07 Sven Neumann <sven@gimp.org>
* libgimpbase/gimpdatafiles.c
......
......@@ -21,12 +21,15 @@
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <process.h> /* for _getpid() */
......@@ -170,10 +173,9 @@ base_toast_old_temp_files (GimpBaseConfig *config)
if (kill (pid, 0))
#endif
{
gchar *filename;
gchar *filename = g_build_filename (dirname, entry, NULL);
filename = g_build_filename (dirname, entry, NULL);
unlink (filename);
g_unlink (filename);
g_free (filename);
}
}
......
......@@ -20,14 +20,15 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <process.h> /* For _getpid() */
......@@ -689,7 +690,8 @@ temp_buf_swap (TempBuf *buf)
}
/* Open file for overwrite */
if ((fp = fopen (filename, "wb")))
fp = g_fopen (filename, "wb");
if (fp)
{
gsize blocks_written;
......@@ -701,20 +703,18 @@ temp_buf_swap (TempBuf *buf)
to flush its buffers */
if ((0 != fclose (fp)) || (1 != blocks_written))
{
unlink (filename);
g_unlink (filename);
perror ("Write error on temp buf");
g_message ("Cannot write \"%s\"",
gimp_filename_to_utf8 (filename));
g_message ("Cannot write \"%s\"", gimp_filename_to_utf8 (filename));
g_free (filename);
return;
}
}
else
{
unlink (filename);
g_unlink (filename);
perror ("Error in temp buf caching");
g_message ("Cannot write \"%s\"",
gimp_filename_to_utf8 (filename));
g_message ("Cannot write \"%s\"", gimp_filename_to_utf8 (filename));
g_free (filename);
return;
}
......@@ -749,7 +749,8 @@ temp_buf_unswap (TempBuf *buf)
if (g_file_test (buf->filename, G_FILE_TEST_IS_REGULAR))
{
if ((fp = fopen (buf->filename, "rb")))
fp = g_fopen (buf->filename, "rb");
if (fp)
{
gsize blocks_read;
......@@ -764,10 +765,12 @@ temp_buf_unswap (TempBuf *buf)
succ = TRUE;
}
else
perror ("Error in temp buf caching");
{
perror ("Error in temp buf caching");
}
/* Delete the swap file */
unlink (buf->filename);
g_unlink (buf->filename);
}
if (!succ)
......@@ -798,15 +801,17 @@ temp_buf_swap_free (TempBuf *buf)
if (g_file_test (buf->filename, G_FILE_TEST_IS_REGULAR))
{
/* Delete the swap file */
unlink (buf->filename);
g_unlink (buf->filename);
}
else
g_message ("Error in temp buf disk swapping: "
"information swapped to disk was lost!");
if (buf->filename)
g_free (buf->filename); /* free filename */
buf->filename = NULL;
{
g_free (buf->filename);
buf->filename = NULL;
}
}
void
......
......@@ -18,19 +18,20 @@
#include "config.h"
#include <stdio.h> /* SEEK_SET */
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef USE_PTHREADS
#include <pthread.h>
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
......@@ -203,7 +204,7 @@ tile_swap_exit1 (gpointer key,
swap_file->fd = -1;
}
#endif
unlink (swap_file->filename);
g_unlink (swap_file->filename);
}
}
......@@ -344,15 +345,15 @@ tile_swap_test (void)
g_assert (swap_file->fd == -1);
/* make sure this duplicates the open() call from tile_swap_open() */
swap_file->fd = open (swap_file->filename,
O_CREAT | O_RDWR | _O_BINARY | _O_TEMPORARY,
S_IREAD | S_IWRITE);
swap_file->fd = g_open (swap_file->filename,
O_CREAT | O_RDWR | _O_BINARY | _O_TEMPORARY,
S_IREAD | S_IWRITE);
if (swap_file->fd != -1)
{
close (swap_file->fd);
swap_file->fd = -1;
unlink (swap_file->filename);
g_unlink (swap_file->filename);
return TRUE;
}
......@@ -447,9 +448,9 @@ tile_swap_open (SwapFile *swap_file)
}
/* duplicate this open() call in tile_swap_test() */
swap_file->fd = open (swap_file->filename,
O_CREAT | O_RDWR | _O_BINARY | _O_TEMPORARY,
S_IRUSR | S_IWUSR);
swap_file->fd = g_open (swap_file->filename,
O_CREAT | O_RDWR | _O_BINARY | _O_TEMPORARY,
S_IRUSR | S_IWUSR);
if (swap_file->fd == -1)
{
......
......@@ -21,12 +21,11 @@
#include "config.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
......@@ -103,7 +102,7 @@ gimp_config_file_copy (const gchar *source,
return FALSE;
}
if (stat (source, &stat_buf) == 0)
if (g_stat (source, &stat_buf) == 0)
{
chmod (dest, stat_buf.st_mode);
}
......
......@@ -20,17 +20,18 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32 /* gets defined by glib.h */
#include <io.h>
......@@ -389,7 +390,7 @@ gimp_brush_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
......
......@@ -20,17 +20,18 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32 /* gets defined by glib.h */
#include <io.h>
......@@ -389,7 +390,7 @@ gimp_brush_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
......
......@@ -21,7 +21,6 @@
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -30,6 +29,7 @@
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
......@@ -247,7 +247,7 @@ gimp_brush_generated_save (GimpData *data,
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gboolean have_shape = FALSE;
file = fopen (data->filename, "wb");
file = g_fopen (data->filename, "wb");
if (! file)
{
......@@ -593,7 +593,7 @@ gimp_brush_generated_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
file = fopen (filename, "rb");
file = g_fopen (filename, "rb");
if (! file)
{
......
......@@ -21,7 +21,6 @@
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -30,6 +29,7 @@
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
......@@ -247,7 +247,7 @@ gimp_brush_generated_save (GimpData *data,
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gboolean have_shape = FALSE;
file = fopen (data->filename, "wb");
file = g_fopen (data->filename, "wb");
if (! file)
{
......@@ -593,7 +593,7 @@ gimp_brush_generated_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
file = fopen (filename, "rb");
file = g_fopen (filename, "rb");
if (! file)
{
......
......@@ -21,7 +21,6 @@
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -30,6 +29,7 @@
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
......@@ -247,7 +247,7 @@ gimp_brush_generated_save (GimpData *data,
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gboolean have_shape = FALSE;
file = fopen (data->filename, "wb");
file = g_fopen (data->filename, "wb");
if (! file)
{
......@@ -593,7 +593,7 @@ gimp_brush_generated_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
file = fopen (filename, "rb");
file = g_fopen (filename, "rb");
if (! file)
{
......
......@@ -24,7 +24,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -35,6 +35,7 @@
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <io.h>
......@@ -330,7 +331,7 @@ gimp_brush_pipe_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
......
......@@ -24,7 +24,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -35,6 +35,7 @@
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <io.h>
......@@ -330,7 +331,7 @@ gimp_brush_pipe_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
......
......@@ -22,7 +22,6 @@
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
......@@ -30,6 +29,7 @@
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
......@@ -308,7 +308,7 @@ gimp_data_delete_from_disk (GimpData *data,
if (data->internal)
return TRUE;
if (unlink (data->filename) == -1)
if (g_unlink (data->filename) == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_DELETE,
_("Could not delete '%s': %s"),
......
......@@ -21,11 +21,11 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
......@@ -229,7 +229,7 @@ gimp_environ_table_get_envp (GimpEnvironTable *environ_table)
/* Hmm.. should we return a copy here in the future? Not thread safe atm,
* but the rest of it isn't either.
*/
*/
if (! environ_table->envp)
gimp_environ_table_populate (environ_table);
......@@ -253,7 +253,7 @@ gimp_environ_table_load_env_file (const GimpDatafileData *file_data,
environ_table = GIMP_ENVIRON_TABLE (user_data);
env = fopen (file_data->filename, "r");
env = g_fopen (file_data->filename, "r");
if (! env)
return;
......@@ -377,7 +377,7 @@ gimp_environ_table_populate (GimpEnvironTable *environ_table)
#ifdef ENVP_DEBUG
var = environ_table->envp;
g_print ("GimpEnvironTable:\n");
g_print ("GimpEnvironTable:\n");
while (*var)
{
g_print ("%s\n", *var);
......
......@@ -18,12 +18,12 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
......@@ -56,7 +56,7 @@ gimp_gradient_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
file = fopen (filename, "rb");
file = g_fopen (filename, "rb");
if (!file)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
......
......@@ -18,11 +18,11 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
......@@ -43,7 +43,7 @@ gimp_gradient_save (GimpData *data,
gint num_segments;
FILE *file;
file = fopen (data->filename, "wb");
file = g_fopen (data->filename, "wb");
if (! file)
{
......@@ -134,7 +134,7 @@ gimp_gradient_save_as_pov (GimpGradient *gradient,
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
file = fopen (filename, "wb");
file = g_fopen (filename, "wb");
if (! file)
{
......
......@@ -25,11 +25,11 @@
#include <unistd.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include "libgimpbase/gimpwin32-io.h"
......@@ -389,7 +389,7 @@ gimp_palette_detect_file_format (const gchar *filename)
guchar header[16];
struct stat file_stat;
fd = open (filename, O_RDONLY);
fd = g_open (filename, O_RDONLY, 0);
if (fd)
{
if (read (fd, header, sizeof (header)) == sizeof (header))
......@@ -433,7 +433,7 @@ gimp_palette_import_from_file (const gchar *filename,
g_return_val_if_fail (palette_name != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY);
fd = g_open (filename, O_RDONLY, 0);
if (! fd)
{
g_set_error (error,
......
......@@ -19,14 +19,15 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
......@@ -352,7 +353,7 @@ gimp_palette_load (const gchar *filename,
r = g = b = 0;
file = fopen (filename, "r");
file = g_fopen (filename, "r");
if (! file)
{
......@@ -559,7 +560,7 @@ gimp_palette_save (GimpData *data,
GList *list;
FILE *file;
file = fopen (data->filename, "w");
file = g_fopen (data->filename, "w");
if (! file)
{
......
......@@ -19,14 +19,15 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
......@@ -352,7 +353,7 @@ gimp_palette_load (const gchar *filename,
r = g = b = 0;
file = fopen (filename, "r");
file = g_fopen (filename, "r");
if (! file)
{
......@@ -559,7 +560,7 @@ gimp_palette_save (GimpData *data,
GList *list;
FILE *file;
file = fopen (data->filename, "w");
file = g_fopen (data->filename, "w");
if (! file)
{
......
......@@ -19,14 +19,15 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
......@@ -352,7 +353,7 @@ gimp_palette_load (const gchar *filename,
r = g = b = 0;
file = fopen (filename, "r");
file = g_fopen (filename, "r");
if (! file)
{
......@@ -559,7 +560,7 @@ gimp_palette_save (GimpData *data,
GList *list;
FILE *file;
file = fopen (data->filename, "w");
file = g_fopen (data->filename, "w");
if (! file)
{
......
......@@ -20,18 +20,19 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <io.h>
......@@ -321,7 +322,7 @@ gimp_pattern_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
......
......@@ -20,18 +20,19 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <io.h>
......@@ -321,7 +322,7 @@ gimp_pattern_load (const gchar *filename,
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY | _O_BINARY);
fd = g_open (filename, O_RDONLY | _O_BINARY, 0);
if (fd == -1)
{
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
......