app/file-open.c app/file-utils.c app/gimprc.c app/plug_in.c

2001-10-24  Michael Natterer  <mitch@gimp.org>

	* app/file-open.c
	* app/file-utils.c
	* app/gimprc.c
	* app/plug_in.c
	* app/user_install.c
	* app/base/base.c
	* app/base/temp-buf.c
	* app/core/gimpdata.c
	* app/core/gimpdatafiles.c
	* app/core/gimpimagefile.c
	* app/gui/about-dialog.c
	* app/gui/file-open-dialog.c
	* app/gui/file-save-dialog.c
	* app/gui/gui.c
	* app/gui/menus.c
	* app/gui/splash.c
	* app/gui/tips-dialog.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimplevelstool.c
	* libgimpbase/gimpenv.c
	* plug-ins/FractalExplorer/FractalExplorer.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gflare/gflare.c
	* tools/pdbgen/pdb/fileops.pdb: use g_build_filename() all over
	the place instead of g_strconcat() and friends together with
	G_DIR_SEPARATOR_S. Also removed all attempts to manually detect
	double dir separators. LibGimpBase's searchpath utility functions
	don't append a G_DIR_SEPARATOR_S to all paths any more.

	* app/pdb/fileops_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2001-10-24 15:56:33 +00:00 committed by Michael Natterer
parent f766956e67
commit 840a9700f4
57 changed files with 689 additions and 670 deletions

View File

@ -1,3 +1,36 @@
2001-10-24 Michael Natterer <mitch@gimp.org>
* app/file-open.c
* app/file-utils.c
* app/gimprc.c
* app/plug_in.c
* app/user_install.c
* app/base/base.c
* app/base/temp-buf.c
* app/core/gimpdata.c
* app/core/gimpdatafiles.c
* app/core/gimpimagefile.c
* app/gui/about-dialog.c
* app/gui/file-open-dialog.c
* app/gui/file-save-dialog.c
* app/gui/gui.c
* app/gui/menus.c
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/tools/gimpcurvestool.c
* app/tools/gimplevelstool.c
* libgimpbase/gimpenv.c
* plug-ins/FractalExplorer/FractalExplorer.c
* plug-ins/gfig/gfig.c
* plug-ins/gflare/gflare.c
* tools/pdbgen/pdb/fileops.pdb: use g_build_filename() all over
the place instead of g_strconcat() and friends together with
G_DIR_SEPARATOR_S. Also removed all attempts to manually detect
double dir separators. LibGimpBase's searchpath utility functions
don't append a G_DIR_SEPARATOR_S to all paths any more.
* app/pdb/fileops_cmds.c: regenerated.
2001-10-24 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpbutton.[ch]: added

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -55,6 +55,7 @@ static void toast_old_temp_files (void);
void
base_init (void)
{
gchar *swapfile;
gchar *path;
#ifdef HAVE_ASM_MMX
@ -68,10 +69,14 @@ base_init (void)
if (base_config->swap_path == NULL)
base_config->swap_path = g_strdup (g_get_tmp_dir ());
path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimpswap.%lu",
base_config->swap_path,
(unsigned long) getpid ());
swapfile = g_strdup_printf ("gimpswap.%lu", (unsigned long) getpid ());
path = g_build_filename (base_config->swap_path, swapfile, NULL);
g_free (swapfile);
tile_swap_add (path, NULL, NULL);
g_free (path);
paint_funcs_setup ();
@ -93,7 +98,6 @@ toast_old_temp_files (void)
{
DIR *dir;
struct dirent *entry;
GString *filename = g_string_new ("");
dir = opendir (base_config->swap_path);
@ -101,7 +105,7 @@ toast_old_temp_files (void)
return;
while ((entry = readdir (dir)) != NULL)
if (!strncmp (entry->d_name, "gimpswap.", 9))
if (! strncmp (entry->d_name, "gimpswap.", 9))
{
/* don't try to kill swap files of running processes
* yes, I know they might not all be gimp processes, and when you
@ -112,20 +116,24 @@ toast_old_temp_files (void)
*/
gint pid = atoi (entry->d_name + 9);
/* On Windows, you can't remove open files anyhow,
* so no harm trying.
*/
#ifndef G_OS_WIN32
if (kill (pid, 0))
#endif
{
/* On Windows, you can't remove open files anyhow,
* so no harm trying.
*/
g_string_printf (filename, "%s" G_DIR_SEPARATOR_S "%s",
base_config->swap_path, entry->d_name);
unlink (filename->str);
gchar *filename;
filename = g_build_filename (base_config->swap_path, entry->d_name,
NULL);
unlink (filename);
g_free (filename);
}
}
closedir (dir);
g_string_free (filename, TRUE);
}

View File

@ -1772,8 +1772,7 @@ file_dialog_create (GtkWidget *parent)
G_CALLBACK (file_dialog_cancel_callback),
NULL);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "curves" G_DIR_SEPARATOR_S,
gimp_directory ());
temp = g_build_filename (gimp_directory (), "curves", NULL);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_dlg), temp);
g_free (temp);

View File

@ -568,13 +568,21 @@ static TempBuf * cached_in_memory = NULL;
static gchar *
generate_unique_filename (void)
{
pid_t pid;
pid_t pid;
gchar *swapfile;
gchar *path;
pid = getpid ();
return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp%d.%d",
base_config->temp_path,
(gint) pid,
swap_index++);
swapfile = g_strdup_printf ("gimp%d.%d",
(gint) pid,
swap_index++);
path = g_build_filename (base_config->temp_path, swapfile, NULL);
g_free (swapfile);
return path;
}
void
@ -593,7 +601,9 @@ temp_buf_swap (TempBuf *buf)
buf->swapped = TRUE;
if (base_config->stingy_memory_use)
swap = buf;
{
swap = buf;
}
else
{
swap = cached_in_memory;

View File

@ -267,6 +267,7 @@ gimp_data_create_filename (GimpData *data,
GList *path;
gchar *dir;
gchar *filename;
gchar *fullpath;
gchar *safe_name;
gint i;
gint unum = 1;
@ -290,27 +291,38 @@ gimp_data_create_filename (GimpData *data,
if (safe_name[i] == G_DIR_SEPARATOR || isspace (safe_name[i]))
safe_name[i] = '_';
filename = g_strdup_printf ("%s%s%s",
dir, safe_name,
filename = g_strdup_printf ("%s%s",
safe_name,
gimp_data_get_extension (data));
while ((file = fopen (filename, "r")))
fullpath = g_build_filename (dir, filename, NULL);
g_free (filename);
while ((file = fopen (fullpath, "r")))
{
fclose (file);
g_free (filename);
filename = g_strdup_printf ("%s%s_%d%s",
dir, safe_name, unum,
g_free (fullpath);
filename = g_strdup_printf ("%s_%d%s",
safe_name,
unum,
gimp_data_get_extension (data));
fullpath = g_build_filename (dir, filename, NULL);
g_free (filename);
unum++;
}
g_free (dir);
g_free (safe_name);
gimp_data_set_filename (data, filename);
gimp_data_set_filename (data, fullpath);
g_free (filename);
g_free (fullpath);
}
GimpData *

View File

@ -171,9 +171,8 @@ gimp_datafiles_read_directories (const gchar *path_str,
continue;
}
filename = g_strdup_printf ("%s%s",
(gchar *) list->data,
dir_ent->d_name);
filename = g_build_filename ((gchar *) list->data,
dir_ent->d_name, NULL);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);

View File

@ -160,9 +160,7 @@ gimp_imagefile_get_new_preview (GimpViewable *viewable,
dirname = g_path_get_dirname (GIMP_OBJECT (imagefile)->name);
basename = g_path_get_basename (GIMP_OBJECT (imagefile)->name);
thumbname = g_strconcat (dirname, G_DIR_SEPARATOR_S,
".xvpics", G_DIR_SEPARATOR_S,
basename, NULL);
thumbname = g_build_filename (dirname, ".xvpics", basename, NULL);
g_free (dirname);
g_free (basename);

View File

@ -316,10 +316,7 @@ about_dialog_load_logo (GtkWidget *window)
if (logo_pixmap)
return TRUE;
filename = g_strconcat (gimp_data_directory (),
G_DIR_SEPARATOR_S,
"gimp_logo.ppm",
NULL);
filename = g_build_filename (gimp_data_directory (), "gimp_logo.ppm", NULL);
fp = fopen (filename, "rb");
g_free (filename);

View File

@ -464,12 +464,10 @@ set_preview (const gchar *fullfname,
gboolean thumb_may_be_outdated = FALSE;
gboolean show_generate_label = TRUE;
dirname = g_path_get_dirname (fullfname);
dirname = g_path_get_dirname (fullfname);
basename = g_path_get_basename (fullfname);
tname = g_strconcat (dirname, G_DIR_SEPARATOR_S,
".xvpics", G_DIR_SEPARATOR_S,
basename, NULL);
tname = g_build_filename (dirname, ".xvpics", basename, NULL);
/* If the file is newer than its thumbnail, the thumbnail may
* be out of date.
@ -644,13 +642,11 @@ file_open_genbutton_callback (GtkWidget *widget,
gtk_file_selection_set_filename (fs, "");
filedirname = g_strdup (gtk_file_selection_get_filename (fs));
if (filedirname[strlen (filedirname) - 1] == G_DIR_SEPARATOR)
filedirname[strlen (filedirname) - 1] = '\0';
while (list)
{
full_filename = g_strconcat (filedirname, G_DIR_SEPARATOR_S,
(gchar *) list->data, NULL);
full_filename = g_build_filename (filedirname,
(gchar *) list->data,
NULL);
err = stat (full_filename, &buf);
@ -700,8 +696,8 @@ file_open_genbutton_callback (GtkWidget *widget,
{
if (! g_slist_next (list))
{
full_filename = g_strconcat (filedirname, G_DIR_SEPARATOR_S,
(gchar *) list->data, NULL);
full_filename = g_build_filename (filedirname,
(gchar *) list->data, NULL);
gtk_file_selection_set_filename (fs, full_filename);
g_free (full_filename);
}
@ -752,7 +748,9 @@ file_open_ok_callback (GtkWidget *widget,
g_free (s);
}
else
gtk_file_selection_set_filename (fs, full_filename);
{
gtk_file_selection_set_filename (fs, full_filename);
}
return;
}
@ -798,8 +796,8 @@ file_open_ok_callback (GtkWidget *widget,
{
g_free (full_filename);
full_filename = g_strconcat (filedirname, G_DIR_SEPARATOR_S,
(gchar *) list->data, NULL);
full_filename = g_build_filename (filedirname,
(gchar *) list->data, NULL);
if (strcmp (list->data, raw_filename))
{ /* don't load current selection twice */

View File

@ -98,6 +98,7 @@ file_save_dialog_menu_init (void)
for (list = save_procs; list; list = g_slist_next (list))
{
gchar *basename;
gchar *filename;
gchar *page;
gchar *lowercase_page;
@ -105,12 +106,14 @@ file_save_dialog_menu_init (void)
basename = g_path_get_basename (file_proc->prog);
page = g_strconcat ("filters", G_DIR_SEPARATOR_S,
basename, ".html",
NULL);
filename = g_strconcat (basename, ".html", NULL);
g_free (basename);
page = g_build_filename ("filters", filename, NULL);
g_free (filename);
lowercase_page = g_ascii_strdown (page, -1);
g_free (page);
@ -393,7 +396,9 @@ file_save_ok_callback (GtkWidget *widget,
g_free (s);
}
else
gtk_file_selection_set_filename (fs, filename);
{
gtk_file_selection_set_filename (fs, filename);
}
}
else
{

View File

@ -75,10 +75,8 @@ tips_dialog_create (void)
{
gchar *temp;
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S TIPS_DIR_NAME
G_DIR_SEPARATOR_S "%s",
gimp_data_directory (),
_("gimp_tips.txt"));
temp = g_build_filename (gimp_data_directory (), TIPS_DIR_NAME,
_("gimp_tips.txt"), NULL);
read_tips_file (temp);
g_free (temp);
}

View File

@ -906,19 +906,19 @@ static gboolean
user_install_run (void)
{
FILE *pfp;
gchar buffer[2048];
gchar *filename = NULL;
gchar *command = NULL;
struct stat stat_buf;
gint err;
gboolean executable = TRUE;
/* Generate output */
g_snprintf (buffer, sizeof (buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL,
gimp_data_directory ());
if ((err = stat (buffer, &stat_buf)) != 0)
filename = g_build_filename (gimp_data_directory (), USER_INSTALL, NULL);
if ((err = stat (filename, &stat_buf)) != 0)
{
gchar *str;
str = g_strdup_printf ("%s\n%s", buffer,
str = g_strdup_printf ("%s\n%s", filename,
_("does not exist. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
@ -929,8 +929,8 @@ user_install_run (void)
else if (! (S_IXUSR & stat_buf.st_mode) || ! (S_IRUSR & stat_buf.st_mode))
{
gchar *str;
str = g_strdup_printf ("%s\n%s", buffer,
str = g_strdup_printf ("%s\n%s", filename,
_("has invalid permissions. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
@ -942,13 +942,13 @@ user_install_run (void)
if (executable)
{
#ifdef G_OS_WIN32
char *quoted_data_dir, *quoted_user_dir, *quoted_sysconf_dir;
gchar *quoted_data_dir, *quoted_user_dir, *quoted_sysconf_dir;
/* On Windows, it is common for the GIMP data directory
* to have spaces in it ("c:\Program Files\GIMP"). Put spaces in quotes.
*/
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
quoted_sysconf_dir = quote_spaces (gimp_sysconf_directory ());
/* The Microsoft _popen doesn't work in Windows applications, sigh.
@ -959,49 +959,64 @@ user_install_run (void)
*/
AllocConsole ();
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s",
quoted_data_dir, quoted_data_dir,
quoted_user_dir, quoted_sysconf_dir);
if (system (buffer) == -1)
executable = FALSE;
g_free (filename);
filename = g_build_filename (quoted_data_dir, USER_INSTALL, NULL);
command = g_strdup_printf ("%s %s %s %s",
fn,
quoted_data_dir,
quoted_user_dir,
quoted_sysconf_dir);
g_free (quoted_data_dir);
g_free (quoted_user_dir);
g_free (quoted_sysconf_dir);
if (system (command) == -1)
executable = FALSE;
if (executable)
add_label (GTK_BOX (log_page),
_("Did you notice any error messages in the console window?\n"
"If not, installation was successful!\n"
"Otherwise, quit and investigate the possible reason..."));
#else
#ifndef __EMX__
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s %s",
gimp_data_directory (),
"2>&1",
gimp_data_directory(), gimp_directory (), gimp_sysconf_directory());
#else
g_snprintf (buffer, sizeof(buffer), "cmd.exe /c %s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s",
gimp_data_directory (), gimp_data_directory(),
gimp_directory (), gimp_sysconf_directory());
#ifdef __EMX__
command = g_strdup_printf ("cmd.exe /c %s %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory());
{
char *s = buffer + 10;
gchar *s = buffer + 11;
while (*s)
{
if (*s == '/') *s = '\\';
s++;
}
}
#else
command = g_strdup_printf ("%s 2>&1 %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory ());
#endif
g_free (filename);
/* urk - should really use something better than popen(), since
* we can't tell if the installation script failed --austin
*/
if ((pfp = popen (buffer, "r")) != NULL)
if ((pfp = popen (command, "r")) != NULL)
{
GtkWidget *scrolled_window;
GtkWidget *log_view;
GtkTextBuffer *log_buffer;
static gchar buffer[2048];
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
@ -1031,10 +1046,14 @@ user_install_run (void)
"Otherwise, quit and investigate the possible reason..."));
}
else
executable = FALSE;
{
executable = FALSE;
}
#endif /* !G_OS_WIN32 */
}
g_free (command);
if (executable)
{
g_object_set_data (G_OBJECT (log_page), "footer",

View File

@ -203,7 +203,7 @@ file_open_absolute_filename (const gchar *name)
return g_strdup (name);
current = g_get_current_dir ();
absolute = g_strconcat (current, G_DIR_SEPARATOR_S, name, NULL);
absolute = g_build_filename (current, name, NULL);
g_free (current);
return absolute;

View File

@ -551,12 +551,8 @@ file_save_thumbnail (GimpImage *gimage,
pathname = g_path_get_dirname (full_source_filename);
filename = g_path_get_basename (full_source_filename);
xvpathname = g_strconcat (pathname, G_DIR_SEPARATOR_S, ".xvpics",
NULL);
thumbnailname = g_strconcat (xvpathname, G_DIR_SEPARATOR_S,
filename,
NULL);
xvpathname = g_build_filename (pathname, ".xvpics", NULL);
thumbnailname = g_build_filename (xvpathname, filename, NULL);
tbd = temp_buf_data (tempbuf);

View File

@ -203,7 +203,7 @@ file_open_absolute_filename (const gchar *name)
return g_strdup (name);
current = g_get_current_dir ();
absolute = g_strconcat (current, G_DIR_SEPARATOR_S, name, NULL);
absolute = g_build_filename (current, name, NULL);
g_free (current);
return absolute;

View File

@ -551,12 +551,8 @@ file_save_thumbnail (GimpImage *gimage,
pathname = g_path_get_dirname (full_source_filename);
filename = g_path_get_basename (full_source_filename);
xvpathname = g_strconcat (pathname, G_DIR_SEPARATOR_S, ".xvpics",
NULL);
thumbnailname = g_strconcat (xvpathname, G_DIR_SEPARATOR_S,
filename,
NULL);
xvpathname = g_build_filename (pathname, ".xvpics", NULL);
thumbnailname = g_build_filename (xvpathname, filename, NULL);
tbd = temp_buf_data (tempbuf);

View File

@ -330,8 +330,7 @@ gimp_system_rc_file (void)
if (! value)
{
value = g_strconcat (gimp_sysconf_directory (), G_DIR_SEPARATOR_S,
"gimprc", NULL);
value = g_build_filename (gimp_sysconf_directory (), "gimprc", NULL);
}
return value;
@ -533,16 +532,10 @@ gimprc_parse_file (const gchar *filename)
if (! g_path_is_absolute (filename))
{
const gchar *home_dir = g_get_home_dir ();
gchar *home_dir_sep;
if (home_dir != NULL)
{
if (home_dir[strlen (home_dir) -1] != G_DIR_SEPARATOR)
home_dir_sep = G_DIR_SEPARATOR_S;
else
home_dir_sep = "";
rfilename = g_strdup_printf ("%s%s%s", home_dir, home_dir_sep,
filename);
rfilename = g_build_filename (home_dir, filename, NULL);
parsed = parse_absolute_gimprc_file (rfilename);
g_free (rfilename);
return parsed;

View File

@ -316,10 +316,7 @@ about_dialog_load_logo (GtkWidget *window)
if (logo_pixmap)
return TRUE;
filename = g_strconcat (gimp_data_directory (),
G_DIR_SEPARATOR_S,
"gimp_logo.ppm",
NULL);
filename = g_build_filename (gimp_data_directory (), "gimp_logo.ppm", NULL);
fp = fopen (filename, "rb");
g_free (filename);

View File

@ -464,12 +464,10 @@ set_preview (const gchar *fullfname,
gboolean thumb_may_be_outdated = FALSE;
gboolean show_generate_label = TRUE;
dirname = g_path_get_dirname (fullfname);
dirname = g_path_get_dirname (fullfname);
basename = g_path_get_basename (fullfname);
tname = g_strconcat (dirname, G_DIR_SEPARATOR_S,
".xvpics", G_DIR_SEPARATOR_S,
basename, NULL);
tname = g_build_filename (dirname, ".xvpics", basename, NULL);
/* If the file is newer than its thumbnail, the thumbnail may
* be out of date.
@ -644,13 +642,11 @@ file_open_genbutton_callback (GtkWidget *widget,
gtk_file_selection_set_filename (fs, "");
filedirname = g_strdup (gtk_file_selection_get_filename (fs));
if (filedirname[strlen (filedirname) - 1] == G_DIR_SEPARATOR)
filedirname[strlen (filedirname) - 1] = '\0';
while (list)
{
full_filename = g_strconcat (filedirname, G_DIR_SEPARATOR_S,
(gchar *) list->data, NULL);
full_filename = g_build_filename (filedirname,
(gchar *) list->data,
NULL);
err = stat (full_filename, &buf);
@ -700,8 +696,8 @@ file_open_genbutton_callback (GtkWidget *widget,
{
if (! g_slist_next (list))
{
full_filename = g_strconcat (filedirname, G_DIR_SEPARATOR_S,
(gchar *) list->data, NULL);
full_filename = g_build_filename (filedirname,
(gchar *) list->data, NULL);
gtk_file_selection_set_filename (fs, full_filename);
g_free (full_filename);
}
@ -752,7 +748,9 @@ file_open_ok_callback (GtkWidget *widget,
g_free (s);
}
else
gtk_file_selection_set_filename (fs, full_filename);
{
gtk_file_selection_set_filename (fs, full_filename);
}
return;
}
@ -798,8 +796,8 @@ file_open_ok_callback (GtkWidget *widget,
{
g_free (full_filename);
full_filename = g_strconcat (filedirname, G_DIR_SEPARATOR_S,
(gchar *) list->data, NULL);
full_filename = g_build_filename (filedirname,
(gchar *) list->data, NULL);
if (strcmp (list->data, raw_filename))
{ /* don't load current selection twice */

View File

@ -98,6 +98,7 @@ file_save_dialog_menu_init (void)
for (list = save_procs; list; list = g_slist_next (list))
{
gchar *basename;
gchar *filename;
gchar *page;
gchar *lowercase_page;
@ -105,12 +106,14 @@ file_save_dialog_menu_init (void)
basename = g_path_get_basename (file_proc->prog);
page = g_strconcat ("filters", G_DIR_SEPARATOR_S,
basename, ".html",
NULL);
filename = g_strconcat (basename, ".html", NULL);
g_free (basename);
page = g_build_filename ("filters", filename, NULL);
g_free (filename);
lowercase_page = g_ascii_strdown (page, -1);
g_free (page);
@ -393,7 +396,9 @@ file_save_ok_callback (GtkWidget *widget,
g_free (s);
}
else
gtk_file_selection_set_filename (fs, filename);
{
gtk_file_selection_set_filename (fs, filename);
}
}
else
{

View File

@ -179,10 +179,7 @@ gui_libs_init (Gimp *gimp,
if (theme_dir)
{
gtkrc = g_strconcat (theme_dir,
G_DIR_SEPARATOR_S,
"gtkrc",
NULL);
gtkrc = g_build_filename (theme_dir, "gtkrc", NULL);
}
else
{

View File

@ -2996,32 +2996,33 @@ menus_debug_recurse_menu (GtkWidget *menu,
}
item_factory = gtk_item_factory_from_path (path);
help_page = (gchar *) g_object_get_data (G_OBJECT (menu_item),
"help_page");
if (item_factory)
{
factory_path =
(gchar *) g_object_get_data (G_OBJECT (item_factory),
"factory_path");
help_page =
g_strconcat (factory_path ? factory_path : "",
factory_path ? G_DIR_SEPARATOR_S : "",
(gchar*) g_object_get_data (G_OBJECT (menu_item),
"help_page"),
NULL);
if (factory_path)
{
help_page = g_build_filename (factory_path, help_page, NULL);
}
else
{
help_page = g_strdup (help_page);
}
}
else
{
help_page =
g_strdup ((gchar *) g_object_get_data (G_OBJECT (menu_item),
"help_page"));
}
help_page = g_strdup (help_page);
}
if (help_page)
{
help_path =
g_strconcat (gimp_data_directory (), G_DIR_SEPARATOR_S,
"help", G_DIR_SEPARATOR_S,
"C", G_DIR_SEPARATOR_S,
help_page, NULL);
help_path = g_build_filename (gimp_data_directory (),
"help", "C", help_page, NULL);
if ((hash = strchr (help_path, '#')) != NULL)
*hash = '\0';

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -212,16 +212,19 @@ static gboolean
splash_logo_load_size (GtkWidget *window)
{
gchar buf[1024];
gchar *filename;
FILE *fp;
if (logo_pixmap)
return TRUE;
g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp_splash.ppm",
gimp_data_directory ());
filename = g_build_filename (gimp_data_directory (), "gimp_splash.ppm", NULL);
fp = fopen (buf, "rb");
if (!fp)
fp = fopen (filename, "rb");
g_free (filename);
if (! fp)
return FALSE;
fgets (buf, sizeof (buf), fp);
@ -246,6 +249,7 @@ splash_logo_load (void)
GtkWidget *preview;
GdkGC *gc;
gchar buf[1024];
gchar *filename;
guchar *pixelrow;
FILE *fp;
gint count;
@ -254,11 +258,13 @@ splash_logo_load (void)
if (! win_initstatus || logo_pixmap || ! splash_show_logo)
return;
g_snprintf (buf, sizeof (buf), "%s" G_DIR_SEPARATOR_S "gimp_splash.ppm",
gimp_data_directory ());
filename = g_build_filename (gimp_data_directory (), "gimp_splash.ppm", NULL);
fp = fopen (buf, "rb");
if (!fp)
fp = fopen (filename, "rb");
g_free (filename);
if (! fp)
return;
fgets (buf, sizeof (buf), fp);
@ -285,7 +291,7 @@ splash_logo_load (void)
for (i = 0; i < logo_height; i++)
{
count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp);
count = fread (pixelrow, sizeof (guchar), logo_width * 3, fp);
if (count != (logo_width * 3))
{
gtk_widget_destroy (preview);

View File

@ -75,10 +75,8 @@ tips_dialog_create (void)
{
gchar *temp;
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S TIPS_DIR_NAME
G_DIR_SEPARATOR_S "%s",
gimp_data_directory (),
_("gimp_tips.txt"));
temp = g_build_filename (gimp_data_directory (), TIPS_DIR_NAME,
_("gimp_tips.txt"), NULL);
read_tips_file (temp);
g_free (temp);
}

View File

@ -906,19 +906,19 @@ static gboolean
user_install_run (void)
{
FILE *pfp;
gchar buffer[2048];
gchar *filename = NULL;
gchar *command = NULL;
struct stat stat_buf;
gint err;
gboolean executable = TRUE;
/* Generate output */
g_snprintf (buffer, sizeof (buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL,
gimp_data_directory ());
if ((err = stat (buffer, &stat_buf)) != 0)
filename = g_build_filename (gimp_data_directory (), USER_INSTALL, NULL);
if ((err = stat (filename, &stat_buf)) != 0)
{
gchar *str;
str = g_strdup_printf ("%s\n%s", buffer,
str = g_strdup_printf ("%s\n%s", filename,
_("does not exist. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
@ -929,8 +929,8 @@ user_install_run (void)
else if (! (S_IXUSR & stat_buf.st_mode) || ! (S_IRUSR & stat_buf.st_mode))
{
gchar *str;
str = g_strdup_printf ("%s\n%s", buffer,
str = g_strdup_printf ("%s\n%s", filename,
_("has invalid permissions. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
@ -942,13 +942,13 @@ user_install_run (void)
if (executable)
{
#ifdef G_OS_WIN32
char *quoted_data_dir, *quoted_user_dir, *quoted_sysconf_dir;
gchar *quoted_data_dir, *quoted_user_dir, *quoted_sysconf_dir;
/* On Windows, it is common for the GIMP data directory
* to have spaces in it ("c:\Program Files\GIMP"). Put spaces in quotes.
*/
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
quoted_sysconf_dir = quote_spaces (gimp_sysconf_directory ());
/* The Microsoft _popen doesn't work in Windows applications, sigh.
@ -959,49 +959,64 @@ user_install_run (void)
*/
AllocConsole ();
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s",
quoted_data_dir, quoted_data_dir,
quoted_user_dir, quoted_sysconf_dir);
if (system (buffer) == -1)
executable = FALSE;
g_free (filename);
filename = g_build_filename (quoted_data_dir, USER_INSTALL, NULL);
command = g_strdup_printf ("%s %s %s %s",
fn,
quoted_data_dir,
quoted_user_dir,
quoted_sysconf_dir);
g_free (quoted_data_dir);
g_free (quoted_user_dir);
g_free (quoted_sysconf_dir);
if (system (command) == -1)
executable = FALSE;
if (executable)
add_label (GTK_BOX (log_page),
_("Did you notice any error messages in the console window?\n"
"If not, installation was successful!\n"
"Otherwise, quit and investigate the possible reason..."));
#else
#ifndef __EMX__
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s %s",
gimp_data_directory (),
"2>&1",
gimp_data_directory(), gimp_directory (), gimp_sysconf_directory());
#else
g_snprintf (buffer, sizeof(buffer), "cmd.exe /c %s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s",
gimp_data_directory (), gimp_data_directory(),
gimp_directory (), gimp_sysconf_directory());
#ifdef __EMX__
command = g_strdup_printf ("cmd.exe /c %s %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory());
{
char *s = buffer + 10;
gchar *s = buffer + 11;
while (*s)
{
if (*s == '/') *s = '\\';
s++;
}
}
#else
command = g_strdup_printf ("%s 2>&1 %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory ());
#endif
g_free (filename);
/* urk - should really use something better than popen(), since
* we can't tell if the installation script failed --austin
*/
if ((pfp = popen (buffer, "r")) != NULL)
if ((pfp = popen (command, "r")) != NULL)
{
GtkWidget *scrolled_window;
GtkWidget *log_view;
GtkTextBuffer *log_buffer;
static gchar buffer[2048];
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
@ -1031,10 +1046,14 @@ user_install_run (void)
"Otherwise, quit and investigate the possible reason..."));
}
else
executable = FALSE;
{
executable = FALSE;
}
#endif /* !G_OS_WIN32 */
}
g_free (command);
if (executable)
{
g_object_set_data (G_OBJECT (log_page), "footer",

View File

@ -2996,32 +2996,33 @@ menus_debug_recurse_menu (GtkWidget *menu,
}
item_factory = gtk_item_factory_from_path (path);
help_page = (gchar *) g_object_get_data (G_OBJECT (menu_item),
"help_page");
if (item_factory)
{
factory_path =
(gchar *) g_object_get_data (G_OBJECT (item_factory),
"factory_path");
help_page =
g_strconcat (factory_path ? factory_path : "",
factory_path ? G_DIR_SEPARATOR_S : "",
(gchar*) g_object_get_data (G_OBJECT (menu_item),
"help_page"),
NULL);
if (factory_path)
{
help_page = g_build_filename (factory_path, help_page, NULL);
}
else
{
help_page = g_strdup (help_page);
}
}
else
{
help_page =
g_strdup ((gchar *) g_object_get_data (G_OBJECT (menu_item),
"help_page"));
}
help_page = g_strdup (help_page);
}
if (help_page)
{
help_path =
g_strconcat (gimp_data_directory (), G_DIR_SEPARATOR_S,
"help", G_DIR_SEPARATOR_S,
"C", G_DIR_SEPARATOR_S,
help_page, NULL);
help_path = g_build_filename (gimp_data_directory (),
"help", "C", help_page, NULL);
if ((hash = strchr (help_path, '#')) != NULL)
*hash = '\0';

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -234,9 +234,7 @@ file_load_thumbnail_invoker (Gimp *gimp,
{
pname = g_path_get_dirname (filename);
fname = g_path_get_basename (filename);
tname = g_strconcat (pname, G_DIR_SEPARATOR_S, ".xvpics", G_DIR_SEPARATOR_S,
fname,
NULL);
tname = g_build_filename (pname, ".xvpics", fname, NULL);
g_free (pname);
g_free (fname);
raw_thumb = readXVThumb (tname, &width, &height, &imginfo);
@ -389,6 +387,7 @@ temp_name_invoker (Gimp *gimp,
gchar *name = NULL;
static gint id = 0;
static gint pid;
gchar *filename;
extension = (gchar *) args[0].value.pdb_pointer;
if (extension == NULL)
@ -399,8 +398,12 @@ temp_name_invoker (Gimp *gimp,
if (id == 0)
pid = getpid();
name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp_temp.%d%d.%s",
base_config->temp_path, pid, id++, extension);
filename = g_strdup_printf ("gimp_temp.%d%d.%s",
pid, id++, extension);
name = g_build_filename (base_config->temp_path, filename, NULL);
g_free (filename);
}
return_args = procedural_db_return_args (&temp_name_proc, success);

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -341,9 +341,9 @@ plug_in_init (Gimp *gimp,
if (g_path_is_absolute (the_gimp->config->pluginrc_path))
filename = g_strdup (the_gimp->config->pluginrc_path);
else
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
gimp_directory (),
the_gimp->config->pluginrc_path);
filename = g_build_filename (gimp_directory (),
the_gimp->config->pluginrc_path,
NULL);
}
else
filename = gimp_personal_rc_file ("pluginrc");
@ -3638,12 +3638,12 @@ static gchar *
plug_in_search_in_path (gchar *search_path,
gchar *filename)
{
static gchar path[256];
gchar *local_path;
gchar *token;
gchar *next_token;
struct stat buf;
gint err;
gchar *local_path;
gchar *token;
gchar *next_token;
gchar *path;
struct stat buf;
gint err;
local_path = g_strdup (search_path);
next_token = local_path;
@ -3651,11 +3651,7 @@ plug_in_search_in_path (gchar *search_path,
while (token)
{
sprintf (path, "%s", token);
if (token[strlen (token) - 1] != G_DIR_SEPARATOR)
strcat (path, G_DIR_SEPARATOR_S);
strcat (path, filename);
path = g_build_filename (token, filename, NULL);
err = stat (path, &buf);
if (!err && S_ISREG (buf.st_mode))
@ -3664,6 +3660,8 @@ plug_in_search_in_path (gchar *search_path,
break;
}
g_free (path);
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
}

View File

@ -1772,8 +1772,7 @@ file_dialog_create (GtkWidget *parent)
G_CALLBACK (file_dialog_cancel_callback),
NULL);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "curves" G_DIR_SEPARATOR_S,
gimp_directory ());
temp = g_build_filename (gimp_directory (), "curves", NULL);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_dlg), temp);
g_free (temp);

View File

@ -1556,8 +1556,7 @@ file_dialog_create (GtkWidget *parent)
G_CALLBACK (file_dialog_cancel_callback),
NULL);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "levels" G_DIR_SEPARATOR_S,
gimp_directory ());
temp = g_build_filename (gimp_directory (), "levels", NULL);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_dlg), temp);
g_free (temp);

View File

@ -906,19 +906,19 @@ static gboolean
user_install_run (void)
{
FILE *pfp;
gchar buffer[2048];
gchar *filename = NULL;
gchar *command = NULL;
struct stat stat_buf;
gint err;
gboolean executable = TRUE;
/* Generate output */
g_snprintf (buffer, sizeof (buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL,
gimp_data_directory ());
if ((err = stat (buffer, &stat_buf)) != 0)
filename = g_build_filename (gimp_data_directory (), USER_INSTALL, NULL);
if ((err = stat (filename, &stat_buf)) != 0)
{
gchar *str;
str = g_strdup_printf ("%s\n%s", buffer,
str = g_strdup_printf ("%s\n%s", filename,
_("does not exist. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
@ -929,8 +929,8 @@ user_install_run (void)
else if (! (S_IXUSR & stat_buf.st_mode) || ! (S_IRUSR & stat_buf.st_mode))
{
gchar *str;
str = g_strdup_printf ("%s\n%s", buffer,
str = g_strdup_printf ("%s\n%s", filename,
_("has invalid permissions. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
@ -942,13 +942,13 @@ user_install_run (void)
if (executable)
{
#ifdef G_OS_WIN32
char *quoted_data_dir, *quoted_user_dir, *quoted_sysconf_dir;
gchar *quoted_data_dir, *quoted_user_dir, *quoted_sysconf_dir;
/* On Windows, it is common for the GIMP data directory
* to have spaces in it ("c:\Program Files\GIMP"). Put spaces in quotes.
*/
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
quoted_data_dir = quote_spaces (gimp_data_directory ());
quoted_user_dir = quote_spaces (gimp_directory ());
quoted_sysconf_dir = quote_spaces (gimp_sysconf_directory ());
/* The Microsoft _popen doesn't work in Windows applications, sigh.
@ -959,49 +959,64 @@ user_install_run (void)
*/
AllocConsole ();
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s",
quoted_data_dir, quoted_data_dir,
quoted_user_dir, quoted_sysconf_dir);
if (system (buffer) == -1)
executable = FALSE;
g_free (filename);
filename = g_build_filename (quoted_data_dir, USER_INSTALL, NULL);
command = g_strdup_printf ("%s %s %s %s",
fn,
quoted_data_dir,
quoted_user_dir,
quoted_sysconf_dir);
g_free (quoted_data_dir);
g_free (quoted_user_dir);
g_free (quoted_sysconf_dir);
if (system (command) == -1)
executable = FALSE;
if (executable)
add_label (GTK_BOX (log_page),
_("Did you notice any error messages in the console window?\n"
"If not, installation was successful!\n"
"Otherwise, quit and investigate the possible reason..."));
#else
#ifndef __EMX__
g_snprintf (buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s %s",
gimp_data_directory (),
"2>&1",
gimp_data_directory(), gimp_directory (), gimp_sysconf_directory());
#else
g_snprintf (buffer, sizeof(buffer), "cmd.exe /c %s" G_DIR_SEPARATOR_S USER_INSTALL " %s %s %s",
gimp_data_directory (), gimp_data_directory(),
gimp_directory (), gimp_sysconf_directory());
#ifdef __EMX__
command = g_strdup_printf ("cmd.exe /c %s %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory());
{
char *s = buffer + 10;
gchar *s = buffer + 11;
while (*s)
{
if (*s == '/') *s = '\\';
s++;
}
}
#else
command = g_strdup_printf ("%s 2>&1 %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory ());
#endif
g_free (filename);
/* urk - should really use something better than popen(), since
* we can't tell if the installation script failed --austin
*/
if ((pfp = popen (buffer, "r")) != NULL)
if ((pfp = popen (command, "r")) != NULL)
{
GtkWidget *scrolled_window;
GtkWidget *log_view;
GtkTextBuffer *log_buffer;
static gchar buffer[2048];
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
@ -1031,10 +1046,14 @@ user_install_run (void)
"Otherwise, quit and investigate the possible reason..."));
}
else
executable = FALSE;
{
executable = FALSE;
}
#endif /* !G_OS_WIN32 */
}
g_free (command);
if (executable)
{
g_object_set_data (G_OBJECT (log_page), "footer",

View File

@ -2996,32 +2996,33 @@ menus_debug_recurse_menu (GtkWidget *menu,
}
item_factory = gtk_item_factory_from_path (path);
help_page = (gchar *) g_object_get_data (G_OBJECT (menu_item),
"help_page");
if (item_factory)
{
factory_path =
(gchar *) g_object_get_data (G_OBJECT (item_factory),
"factory_path");
help_page =
g_strconcat (factory_path ? factory_path : "",
factory_path ? G_DIR_SEPARATOR_S : "",
(gchar*) g_object_get_data (G_OBJECT (menu_item),
"help_page"),
NULL);
if (factory_path)
{
help_page = g_build_filename (factory_path, help_page, NULL);
}
else
{
help_page = g_strdup (help_page);
}
}
else
{
help_page =
g_strdup ((gchar *) g_object_get_data (G_OBJECT (menu_item),
"help_page"));
}
help_page = g_strdup (help_page);
}
if (help_page)
{
help_path =
g_strconcat (gimp_data_directory (), G_DIR_SEPARATOR_S,
"help", G_DIR_SEPARATOR_S,
"C", G_DIR_SEPARATOR_S,
help_page, NULL);
help_path = g_build_filename (gimp_data_directory (),
"help", "C", help_page, NULL);
if ((hash = strchr (help_path, '#')) != NULL)
*hash = '\0';

View File

@ -171,9 +171,8 @@ gimp_datafiles_read_directories (const gchar *path_str,
continue;
}
filename = g_strdup_printf ("%s%s",
(gchar *) list->data,
dir_ent->d_name);
filename = g_build_filename ((gchar *) list->data,
dir_ent->d_name, NULL);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);

View File

@ -86,38 +86,31 @@ gimp_directory (void)
const gchar *env_gimp_dir;
const gchar *home_dir;
gchar *home_dir_sep;
if (gimp_dir != NULL)
return gimp_dir;
env_gimp_dir = g_getenv ("GIMP_DIRECTORY");
home_dir = g_get_home_dir ();
home_dir = g_get_home_dir ();
if (home_dir != NULL && home_dir[strlen (home_dir)-1] != G_DIR_SEPARATOR)
home_dir_sep = G_DIR_SEPARATOR_S;
else
home_dir_sep = "";
if (NULL != env_gimp_dir)
if (env_gimp_dir)
{
if (g_path_is_absolute (env_gimp_dir))
gimp_dir = g_strdup (env_gimp_dir);
{
gimp_dir = g_strdup (env_gimp_dir);
}
else
{
if (NULL != home_dir)
if (home_dir)
{
gimp_dir = g_strconcat (home_dir,
home_dir_sep,
env_gimp_dir,
NULL);
gimp_dir = g_build_filename (home_dir,
env_gimp_dir,
NULL);
}
else
{
gimp_dir = g_strconcat (gimp_data_directory (),
G_DIR_SEPARATOR_S,
env_gimp_dir,
NULL);
gimp_dir = g_build_filename (gimp_data_directory (),
env_gimp_dir, NULL);
}
}
}
@ -129,22 +122,17 @@ gimp_directory (void)
#endif
if (NULL != home_dir)
{
gimp_dir = g_strconcat (home_dir,
home_dir_sep,
GIMPDIR,
NULL);
gimp_dir = g_build_filename (home_dir, GIMPDIR, NULL);
}
else
{
#ifndef G_OS_WIN32
g_message ("warning: no home directory.");
#endif
gimp_dir = g_strconcat (gimp_data_directory (),
G_DIR_SEPARATOR_S,
GIMPDIR,
".",
g_get_user_name (),
NULL);
gimp_dir = g_build_filename (gimp_data_directory (),
GIMPDIR ".",
g_get_user_name (),
NULL);
}
}
@ -276,12 +264,12 @@ gimp_sysconf_directory (void)
if (NULL != env_gimp_sysconf_dir)
{
if (!g_path_is_absolute (env_gimp_sysconf_dir))
if (! g_path_is_absolute (env_gimp_sysconf_dir))
g_error ("GIMP_SYSCONFDIR environment variable should be an absolute path.");
#ifndef __EMX__
gimp_sysconf_dir = g_strdup (env_gimp_sysconf_dir);
#else
gimp_sysconf_dir = g_strdup (__XOS2RedirRoot(env_gimp_sysconf_dir));
gimp_sysconf_dir = g_strdup (__XOS2RedirRoot (env_gimp_sysconf_dir));
#endif
}
else
@ -290,7 +278,7 @@ gimp_sysconf_directory (void)
#ifndef __EMX__
gimp_sysconf_dir = SYSCONFDIR;
#else
gimp_sysconf_dir = g_strdup(__XOS2RedirRoot(SYSCONFDIR));
gimp_sysconf_dir = g_strdup (__XOS2RedirRoot(SYSCONFDIR));
#endif
#else
/* Figure it out from the executable name */
@ -340,32 +328,25 @@ gimp_gtkrc (void)
{
static gchar *gimp_gtkrc_filename = NULL;
if (gimp_gtkrc_filename != NULL)
return gimp_gtkrc_filename;
gimp_gtkrc_filename = g_strconcat (gimp_data_directory (),
G_DIR_SEPARATOR_S,
"themes",
G_DIR_SEPARATOR_S,
"Default",
G_DIR_SEPARATOR_S,
"gtkrc",
NULL);
if (! gimp_gtkrc_filename)
{
gimp_gtkrc_filename = g_build_filename (gimp_data_directory (),
"themes", "Default", "gtkrc",
NULL);
}
return gimp_gtkrc_filename;
}
/**
* gimp_path_parse:
* @path: A list of directories separated by #G_SEARCHPATH_SEPARATOR.
* @max_paths: The maximum number of directories to return.
* @check: #TRUE if you want the directories to be checked.
* @path: A list of directories separated by #G_SEARCHPATH_SEPARATOR.
* @max_paths: The maximum number of directories to return.
* @check: #TRUE if you want the directories to be checked.
* @check_failed: Returns a #GList of path elements for which the
* check failed. Each list element is guaranteed
* to end with a #G_PATH_SEPARATOR.
* check failed.
*
* Returns: A #GList of all directories in @path. Each list element
* is guaranteed to end with a #G_PATH_SEPARATOR.
* Returns: A #GList of all directories in @path.
**/
GList *
gimp_path_parse (const gchar *path,
@ -375,7 +356,7 @@ gimp_path_parse (const gchar *path,
{
const gchar *home;
gchar **patharray;
GList *list = NULL;
GList *list = NULL;
GList *fail_list = NULL;
gint i;
@ -412,17 +393,9 @@ gimp_path_parse (const gchar *path,
_fnslashify (dir);
#endif
/* check if directory exists */
if (check)
{
/* check if directory exists */
err = stat (dir->str, &filestat);
if (!err && S_ISDIR (filestat.st_mode))
{
if (dir->str[dir->len - 1] != G_DIR_SEPARATOR)
g_string_append_c (dir, G_DIR_SEPARATOR);
}
}
err = stat (dir->str, &filestat);
if (!err)
list = g_list_prepend (list, g_strdup (dir->str));
@ -491,15 +464,12 @@ gimp_path_free (GList *path)
{
GList *list;
if (path)
for (list = path; list; list = g_list_next (list))
{
for (list = path; list; list = g_list_next (list))
{
g_free (list->data);
}
g_list_free (path);
g_free (list->data);
}
g_list_free (path);
}
/**
@ -521,30 +491,19 @@ gimp_path_get_user_writable_dir (GList *path)
struct stat filestat;
gint err;
g_return_val_if_fail (path != NULL, NULL);
euid = geteuid ();
egid = getegid ();
for (list = path; list; list = g_list_next (list))
{
/* check if directory exists */
/* ugly hack to handle paths with an extra G_DIR_SEPARATOR
* attached. The stat() in MSVCRT doesn't like that.
*/
gchar *dir;
gchar *p;
gint pl;
p = dir = g_strdup ((gchar *) list->data);
dir = (gchar *) list->data;
if (g_path_is_absolute (dir))
p = (gchar *) g_path_skip_root (dir);
pl = strlen (p);
if (pl > 0 && p[pl-1] == G_DIR_SEPARATOR)
p[pl-1] = '\0';
/* check if directory exists */
err = stat (dir, &filestat);
g_free (dir);
/* this is tricky:
* if a file is e.g. owned by the current user but not user-writable,
@ -562,7 +521,7 @@ gimp_path_get_user_writable_dir (GList *path)
(euid != filestat.st_uid) &&
(egid != filestat.st_gid))))
{
return g_strdup ((gchar *) list->data);
return g_strdup (dir);
}
}

View File

@ -878,7 +878,7 @@ new_fractalexplorer_obj (gchar *name)
if (!name)
name = _("New Fractal");
fractalexplorer->draw_name = g_strdup(name);
fractalexplorer->draw_name = g_strdup (name);
/* Leave options as before */
pic_obj = current_obj = fractalexplorer;
@ -1279,15 +1279,14 @@ fractalexplorer_load (gchar *filename,
static void
fractalexplorer_list_load_all (GList *plist)
{
fractalexplorerOBJ * fractalexplorer;
GList * list;
gchar * path;
gchar * filename;
DIR * dir;
struct dirent *dir_ent;
struct stat filestat;
gint err;
gchar pathlast;
fractalexplorerOBJ *fractalexplorer;
GList *list;
gchar *path;
gchar *filename;
DIR *dir;
struct dirent *dir_ent;
struct stat filestat;
gint err;
/* Make sure to clear any existing fractalexplorers */
current_obj = pic_obj = NULL;
@ -1297,21 +1296,19 @@ fractalexplorer_list_load_all (GList *plist)
{
path = list->data;
list = list->next;
pathlast = path[strlen (path) - 1];
/* Open directory */
dir = opendir (path);
if (!dir)
g_warning ("error reading fractalexplorer directory \"%s\"", path);
{
g_warning ("error reading fractalexplorer directory \"%s\"", path);
}
else
{
while ((dir_ent = readdir (dir)))
{
filename = g_strdup_printf
("%s%s%s", path,
(pathlast == G_DIR_SEPARATOR ? "" : G_DIR_SEPARATOR_S),
dir_ent->d_name);
filename = g_build_filename (path, dir_ent->d_name, NULL);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);
@ -1332,17 +1329,17 @@ fractalexplorer_list_load_all (GList *plist)
}
g_free (filename);
} /* while */
}
closedir (dir);
} /* else */
}
}
if(!fractalexplorer_list)
{
/* lets have at least one! */
fractalexplorer = fractalexplorer_new();
fractalexplorer->draw_name = g_strdup(_("My first fractal"));
fractalexplorer_list_insert(fractalexplorer);
fractalexplorer = fractalexplorer_new ();
fractalexplorer->draw_name = g_strdup (_("My first fractal"));
fractalexplorer_list_insert (fractalexplorer);
}
pic_obj = current_obj = fractalexplorer_list->data; /* set to first entry */

View File

@ -998,14 +998,14 @@ gfig_list_free_all (void)
static void
gfig_list_load_all (GList *plist)
{
GFigObj *gfig;
GList *list;
gchar *path;
gchar *filename;
DIR *dir;
GFigObj *gfig;
GList *list;
gchar *path;
gchar *filename;
DIR *dir;
struct dirent *dir_ent;
struct stat filestat;
gint err;
gint err;
/* Make sure to clear any existing gfigs */
current_obj = pic_obj = NULL;
@ -1026,9 +1026,7 @@ gfig_list_load_all (GList *plist)
{
while ((dir_ent = readdir (dir)))
{
filename = g_malloc (strlen (path) + strlen (dir_ent->d_name) + 1);
sprintf (filename, "%s%s", path, dir_ent->d_name);
filename = g_build_filename (path, dir_ent->d_name, NULL);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);
@ -1048,9 +1046,9 @@ gfig_list_load_all (GList *plist)
}
g_free (filename);
} /* while */
}
closedir (dir);
} /* else */
}
}
if (!gfig_list)

View File

@ -1611,7 +1611,7 @@ gflare_save (GFlare *gflare)
if (!path)
path = g_strdup (gimp_directory ());
gflare->filename = g_strdup_printf ("%s%s", path, gflare->name);
gflare->filename = g_build_filename ("%s%s", path, gflare->name, NULL);
g_free (path);
}
@ -1814,7 +1814,7 @@ gflares_list_load_all (void)
{
while ((dir_ent = readdir (dir)))
{
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
filename = g_build_filename (path, dir_ent->d_name, NULL);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);

View File

@ -193,9 +193,7 @@ HELP
{
pname = g_path_get_dirname (filename);
fname = g_path_get_basename (filename);
tname = g_strconcat (pname, G_DIR_SEPARATOR_S, ".xvpics", G_DIR_SEPARATOR_S,
fname,
NULL);
tname = g_build_filename (pname, ".xvpics", fname, NULL);
g_free (pname);
g_free (fname);
raw_thumb = readXVThumb (tname, &width, &height, &imginfo);
@ -274,14 +272,18 @@ HELP
%invoke = (
headers => [ qw(<process.h> "base/base-config.h") ],
vars => [ 'static gint id = 0', 'static gint pid' ],
vars => [ 'static gint id = 0', 'static gint pid', 'gchar *filename' ],
code => <<'CODE'
{
if (id == 0)
pid = getpid();
name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp_temp.%d%d.%s",
base_config->temp_path, pid, id++, extension);
filename = g_strdup_printf ("gimp_temp.%d%d.%s",
pid, id++, extension);
name = g_build_filename (base_config->temp_path, filename, NULL);
g_free (filename);
}
CODE
);