Commit fe2c9e8b authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/app_procs.c app/base/temp-buf.c app/core/gimpmodules.c

2002-02-18  Sven Neumann  <sven@gimp.org>

	* app/app_procs.c
	* app/base/temp-buf.c
	* app/core/gimpmodules.c
	* app/plug-in/plug-in.c
	* libgimpbase/gimpenv.c
	* libgimpwidgets/gimpfileselection.c
	* plug-ins/FractalExplorer/Dialogs.c
	* plug-ins/FractalExplorer/FractalExplorer.c
	* plug-ins/flame/flame.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gflare/gflare.c
	* plug-ins/gimpressionist/gimpressionist.[ch]: use g_file_test()
	instead of stat() whereever possible. Improves code readability.
parent fb8c94c0
2002-02-18 Sven Neumann <sven@gimp.org>
* app/app_procs.c
* app/base/temp-buf.c
* app/core/gimpmodules.c
* app/plug-in/plug-in.c
* libgimpbase/gimpenv.c
* libgimpwidgets/gimpfileselection.c
* plug-ins/FractalExplorer/Dialogs.c
* plug-ins/FractalExplorer/FractalExplorer.c
* plug-ins/flame/flame.c
* plug-ins/gfig/gfig.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.[ch]: use g_file_test()
instead of stat() whereever possible. Improves code readability.
2002-02-18 Sven Neumann <sven@gimp.org>
* configure.in: require latest glib and gtk+ releases (1.3.14).
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -21,11 +21,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -83,7 +83,6 @@ app_init (gint gimp_argc,
gchar **gimp_argv)
{
const gchar *gimp_dir;
struct stat stat_buf;
/* Create an instance of the "Gimp" object which is the root of the
* core object system
......@@ -99,7 +98,7 @@ app_init (gint gimp_argc,
*/
gimp_dir = gimp_directory ();
if (stat (gimp_dir, &stat_buf) != 0)
if (!g_file_test (gimp_dir, G_FILE_TEST_IS_DIR))
{
/* not properly installed */
......
......@@ -25,8 +25,6 @@
#include <unistd.h>
#endif
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <glib-object.h>
......@@ -624,8 +622,6 @@ temp_buf_swap (TempBuf *buf)
{
TempBuf *swap;
gchar *filename;
struct stat stat_buf;
gint err;
FILE *fp;
if (!buf || buf->swapped)
......@@ -654,16 +650,12 @@ temp_buf_swap (TempBuf *buf)
filename = generate_unique_filename ();
/* Check if generated filename is valid */
err = stat (filename, &stat_buf);
if (!err)
{
if (stat_buf.st_mode & S_IFDIR)
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
{
g_message ("Error in temp buf caching: \"%s\" is a directory (cannot overwrite)", filename);
g_free (filename);
return;
}
}
/* Open file for overwrite */
if ((fp = fopen (filename, "wb")))
......@@ -698,7 +690,6 @@ temp_buf_swap (TempBuf *buf)
void
temp_buf_unswap (TempBuf *buf)
{
struct stat stat_buf;
FILE *fp;
gboolean succ = FALSE;
......@@ -718,9 +709,7 @@ temp_buf_unswap (TempBuf *buf)
/* Allocate memory for the buffer's data */
buf->data = temp_buf_allocate (buf->width * buf->height * buf->bytes);
/* Find out if the filename of the swapped data is an existing file... */
/* (buf->filname HAS to be != 0 */
if (!stat (buf->filename, &stat_buf))
if (g_file_test (buf->filename, G_FILE_TEST_IS_REGULAR))
{
if ((fp = fopen (buf->filename, "rb")))
{
......@@ -748,8 +737,6 @@ temp_buf_unswap (TempBuf *buf)
void
temp_buf_swap_free (TempBuf *buf)
{
struct stat stat_buf;
if (!buf->swapped)
return;
......@@ -764,7 +751,7 @@ temp_buf_swap_free (TempBuf *buf)
}
/* Find out if the filename of the swapped data is an existing file... */
if (!stat (buf->filename, &stat_buf))
if (g_file_test (buf->filename, G_FILE_TEST_IS_REGULAR))
{
/* Delete the swap file */
unlink (buf->filename);
......
......@@ -23,8 +23,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -359,19 +358,14 @@ gimp_modules_module_on_disk_func (gpointer data,
GimpModuleInfoObj *module_info;
GList **kill_list;
gint old_on_disk;
struct stat statbuf;
gint ret;
module_info = (GimpModuleInfoObj *) data;
kill_list = (GList **) user_data;
old_on_disk = module_info->on_disk;
ret = stat (module_info->fullpath, &statbuf);
if (ret != 0)
module_info->on_disk = FALSE;
else
module_info->on_disk = TRUE;
module_info->on_disk = g_file_test (module_info->fullpath,
G_FILE_TEST_IS_REGULAR);
/* if it's not on the disk, and it isn't in memory, mark it to be
* removed later.
......
......@@ -23,8 +23,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -359,19 +358,14 @@ gimp_modules_module_on_disk_func (gpointer data,
GimpModuleInfoObj *module_info;
GList **kill_list;
gint old_on_disk;
struct stat statbuf;
gint ret;
module_info = (GimpModuleInfoObj *) data;
kill_list = (GList **) user_data;
old_on_disk = module_info->on_disk;
ret = stat (module_info->fullpath, &statbuf);
if (ret != 0)
module_info->on_disk = FALSE;
else
module_info->on_disk = TRUE;
module_info->on_disk = g_file_test (module_info->fullpath,
G_FILE_TEST_IS_REGULAR);
/* if it's not on the disk, and it isn't in memory, mark it to be
* removed later.
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
......@@ -3532,8 +3529,7 @@ plug_in_search_in_path (gchar *search_path,
{
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
token = path;
break;
......
......@@ -33,8 +33,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
......@@ -3521,8 +3520,6 @@ plug_in_search_in_path (gchar *search_path,
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);