use proper defines to specify the permissions when calling mkdir().

2002-12-30  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimagefile.c (gimp_imagefile_png_thumb_path): use
	proper defines to specify the permissions when calling mkdir().

	* app/file/file-utils.c: removed redeclaration of mkdir() for
	Win32 since we don't call mkdir() here.

	* app/gui/user-install-dialog.c (user_install_run): rewrote
	copy_file() to use GError for error reporting. Use the same code
	for the user installation on all platforms. Also fixes bug #102015.

	* data/misc/Makefile.am
	* data/misc/user_install
	* data/misc/user_install.bat: removed obsoleted scripts.
This commit is contained in:
Sven Neumann 2002-12-30 17:27:58 +00:00 committed by Sven Neumann
parent b7e1bb247b
commit 42b01c5256
8 changed files with 202 additions and 484 deletions

View File

@ -1,19 +1,35 @@
2002-12-30 Sven Neumann <sven@gimp.org>
* app/core/gimpimagefile.c (gimp_imagefile_png_thumb_path): use
proper defines to specify the permissions when calling mkdir().
* app/file/file-utils.c: removed redeclaration of mkdir() for
Win32 since we don't call mkdir() here.
* app/gui/user-install-dialog.c (user_install_run): rewrote
copy_file() to use GError for error reporting. Use the same code
for the user installation on all platforms. Also fixes bug #102015.
* data/misc/Makefile.am
* data/misc/user_install
* data/misc/user_install.bat: removed obsoleted scripts.
2002-12-30 Simon Budig <simon@gimp.org>
* app/vectors/gimpanchor.h
* app/vectors/vectors-types.h: Anchors now have an enum as type and
* app/vectors/vectors-types.h: anchors now have an enum as type and
have the "selected" property.
* app/vectors/gimpstroke.[ch]
* app/vectors/gimpbezierstroke.c
* app/vectors/gimpvectors-preview.c: Additional functions to get
information about the graphical representation of the stroke and be
able to select anchors.
* app/vectors/gimpbezierstroke.c
* app/vectors/gimpvectors-preview.c: additional functions to get
information about the graphical representation of the stroke and
to be able to select anchors.
* app/tools/gimpvectortool.c: semi-usable interface, better graphical
representation of what is going on. Also make use of the "selected"
property of the anhors to just display a subset of the control
handles.
* app/tools/gimpvectortool.c: semi-usable interface, better
graphical representation of what is going on. Make use of the
"selected" property of the anchors to just display a subset of the
control handles.
2002-12-30 Sven Neumann <sven@gimp.org>

View File

@ -1046,12 +1046,12 @@ gimp_imagefile_png_thumb_path (const gchar *uri,
if (! g_file_test (thumb_subdirs[i], G_FILE_TEST_IS_DIR))
{
if (g_file_test (thumb_dir, G_FILE_TEST_IS_DIR) ||
(mkdir (thumb_dir, 0700) == 0))
(mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
{
if (i == 0)
mkdir (thumb_fail_subdir, 0700);
mkdir (thumb_fail_subdir, S_IRUSR | S_IWUSR | S_IXUSR);
mkdir (thumb_subdirs[i], 0700);
mkdir (thumb_subdirs[i], S_IRUSR | S_IWUSR | S_IXUSR);
}
if (! g_file_test (thumb_subdirs[i], G_FILE_TEST_IS_DIR))

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
@ -47,25 +48,21 @@
#include "libgimp/gimpintl.h"
#ifndef G_OS_WIN32
# ifndef __EMX__
# define USER_INSTALL "user_install"
# else
# include <process.h>
# define USER_INSTALL "user_install.cmd"
# endif
#else
#ifdef G_OS_WIN32
# include <io.h>
# define mkdir(path, mode) _mkdir(path)
#endif
#define NUM_PAGES 6
#define EEK_PAGE (NUM_PAGES - 1)
#define PAGE_STYLE(widget) gtk_widget_modify_style (widget, page_style)
#define TITLE_STYLE(widget) gtk_widget_modify_style (widget, title_style)
enum {
enum
{
DIRENT_COLUMN,
PIXBUF_COLUMN,
DESC_COLUMN,
@ -933,203 +930,85 @@ user_install_dialog_create (const gchar *alternate_system_gimprc,
/*********************/
/* Local functions */
#ifdef G_OS_WIN32
static gchar *install_error_message;
static int
copy_file (gchar *source,
gchar *dest)
static gboolean
copy_file (gchar *source,
gchar *dest,
GError **error)
{
char buffer[4096];
FILE *sfile, *dfile;
int nbytes;
FILE *sfile;
FILE *dfile;
gchar buffer[4096];
gsize nbytes;
sfile = fopen (source, "rb");
if (sfile == NULL)
{
install_error_message = g_strdup_printf (_("Cannot open %s for reading"),
source);
return -1;
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot open '%s' for reading: %s"),
source, g_strerror (errno));
return FALSE;
}
dfile = fopen (dest, "wb");
if (dfile == NULL)
{
install_error_message = g_strdup_printf (_("Cannot open %s for writing"),
dest);
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot open '%s' for writing: %s"),
dest, g_strerror (errno));
fclose (sfile);
return -1;
return FALSE;
}
while ((nbytes = fread (buffer, 1, sizeof (buffer), sfile)) > 0)
{
if (fwrite (buffer, 1, nbytes, dfile) < nbytes)
{
install_error_message = g_strdup_printf (_("Error while writing %s"),
dest);
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error writing to '%s': %s"),
dest, g_strerror (errno));
fclose (sfile);
fclose (dfile);
return -1;
return FALSE;
}
}
if (ferror (sfile))
{
install_error_message = g_strdup_printf (_("Error while reading %s"),
source);
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error reading from '%s': %s"),
source, g_strerror (errno));
fclose (sfile);
fclose (dfile);
return -1;
return FALSE;
}
fclose (sfile);
fclose (dfile);
return 0;
}
#endif
return TRUE;
}
static gboolean
user_install_run (void)
{
#ifndef G_OS_WIN32
FILE *pfp;
gchar *filename = NULL;
gchar *command = NULL;
struct stat stat_buf;
gint err;
gboolean executable = TRUE;
filename = g_build_filename (gimp_data_directory (), "misc",
USER_INSTALL, NULL);
if ((err = stat (filename, &stat_buf)) != 0)
{
gchar *str;
str = g_strdup_printf ("%s\n%s", filename,
_("does not exist. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
executable = FALSE;
}
#ifdef S_IXUSR
else if (! (S_IXUSR & stat_buf.st_mode) || ! (S_IRUSR & stat_buf.st_mode))
{
gchar *str;
str = g_strdup_printf ("%s\n%s", filename,
_("has invalid permissions. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
executable = FALSE;
}
#endif
if (executable)
{
#ifdef __EMX__
command = g_strdup_printf ("cmd.exe /c %s %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory());
{
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 (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),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (log_page), scrolled_window,
TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
log_buffer = gtk_text_buffer_new (NULL);
log_view = gtk_text_view_new_with_buffer (log_buffer);
g_object_unref (log_buffer);
PAGE_STYLE (log_view);
gtk_text_view_set_editable (GTK_TEXT_VIEW (log_view), FALSE);
gtk_container_add (GTK_CONTAINER (scrolled_window), log_view);
gtk_widget_show (log_view);
while (fgets (buffer, sizeof (buffer), pfp))
{
gtk_text_buffer_insert_at_cursor (log_buffer, buffer, -1);
}
pclose (pfp);
add_label (GTK_BOX (log_page),
_("Did you notice any error messages in the lines above?\n"
"If not, installation was successful!\n"
"Otherwise, quit and investigate the possible reason..."));
}
else
{
executable = FALSE;
}
}
g_free (command);
if (executable)
{
g_object_set_data (G_OBJECT (log_page), "footer",
_("Click \"Continue\" to complete GIMP installation."));
}
else
{
add_label (GTK_BOX (log_page),
_("Installation failed. Contact your system administrator."));
}
return executable;
#else
GtkWidget *scrolled_window;
GtkWidget *scrolled_window;
GtkTextBuffer *log_buffer;
GtkWidget *log_view;
gchar dest[1000];
gchar source[1000];
gchar log_line[1000];
gint i;
GtkWidget *log_view;
GError *error = NULL;
gchar dest[1000];
gchar source[1000];
gchar log_line[1000];
gint i;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (log_page), scrolled_window,
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (log_page), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
log_buffer = gtk_text_buffer_new (NULL);
@ -1147,32 +1026,45 @@ user_install_run (void)
{
if (i == 0)
{
g_snprintf (log_line, sizeof (log_line), _("Creating folder %s\n"),
gimp_directory ());
g_snprintf (log_line, sizeof (log_line),
_("Creating folder %s\n"), gimp_directory ());
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
if (mkdir (gimp_directory (), 0666) == -1)
if (mkdir (gimp_directory (),
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH) == -1)
{
install_error_message = g_strdup_printf (_("Cannot create folder: %s"),
g_strerror (errno));
g_set_error (&error,
G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot create folder: %s"), g_strerror (errno));
goto break_out_of_loop;
}
gtk_text_buffer_insert_at_cursor (log_buffer, _(" Success\n"), -1);
}
g_snprintf (dest, sizeof (dest), "%s%c%s",
gimp_directory (), G_DIR_SEPARATOR, tree_items[i].text);
switch (tree_items[i].type)
{
case TREE_ITEM_DONT:
break;
case TREE_ITEM_MKDIR_ONLY:
g_snprintf (log_line, sizeof (log_line), _("Creating folder %s\n"),
dest);
g_snprintf (log_line, sizeof (log_line),
_("Creating folder %s\n"), dest);
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
if (mkdir (dest, 0666) == -1)
if (mkdir (dest,
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH) == -1)
{
install_error_message = g_strdup_printf (_("Cannot create folder: %s"),
g_strerror (errno));
g_set_error (&error,
G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot create folder: %s"), g_strerror (errno));
goto break_out_of_loop;
}
break;
@ -1191,35 +1083,41 @@ user_install_run (void)
tree_items[i].source_filename : tree_items[i].text);
do_copy:
g_assert (!tree_items[i].directory);
g_snprintf (log_line, sizeof (log_line), _("Copying file %s from %s\n"),
dest, source);
g_snprintf (log_line, sizeof (log_line),
_("Copying file %s from %s\n"), dest, source);
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
if (copy_file (source, dest) == -1)
if (!copy_file (source, dest, &error))
goto break_out_of_loop;
break;
default:
g_assert_not_reached ();
break;
}
if (tree_items[i].type != TREE_ITEM_DONT)
gtk_text_buffer_insert_at_cursor (log_buffer, _(" Success\n"), -1);
}
break_out_of_loop:
if (i < num_tree_items)
if (error)
{
g_snprintf (log_line, sizeof (log_line), _(" Failure: %s\n"),
install_error_message);
error->message);
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
add_label (GTK_BOX (log_page),
_("Installation failed. Contact system administrator."));
g_error_free (error);
return FALSE;
}
return TRUE;
#endif
}
static void

View File

@ -31,13 +31,6 @@
#include <unistd.h>
#endif
#include <glib.h>
#ifdef G_OS_WIN32
#include <direct.h> /* For _mkdir() */
#define mkdir(path,mode) _mkdir(path)
#endif
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"
@ -488,8 +481,9 @@ file_check_single_magic (gchar *offset,
if (!g_ascii_isdigit (value[0])) return (0);
/*
* to anybody reading this: is strtol's parsing behaviour (e.g. "0x" prefix)
* broken on some systems or why do we do the base detection ourselves?
* to anybody reading this: is strtol's parsing behaviour
* (e.g. "0x" prefix) broken on some systems or why do we
* do the base detection ourselves?
* */
if (value[0] != '0') /* decimal */
num_testval = strtol(value, NULL, 10);
@ -579,6 +573,7 @@ file_check_magic_list (GSList *magics_list,
if ((type = (gchar *)magics_list->data) == NULL) break;
if ((magics_list = magics_list->next) == NULL) break;
if ((value = (gchar *)magics_list->data) == NULL) break;
magics_list = magics_list->next;
match_val = file_check_single_magic (offset, type, value,
@ -606,13 +601,13 @@ readXVThumb (const gchar *fnam,
gint *h,
gchar **imginfo /* caller frees if != NULL */)
{
FILE *fp;
FILE *fp;
const gchar *P7_332 = "P7 332";
gchar P7_buf[7];
gchar linebuf[200];
guchar *buf;
gint twofivefive;
void *ptr;
gchar P7_buf[7];
gchar linebuf[200];
guchar *buf;
gint twofivefive;
void *ptr;
*w = *h = 0;
*imginfo = NULL;
@ -623,7 +618,7 @@ readXVThumb (const gchar *fnam,
fread (P7_buf, 6, 1, fp);
if (strncmp(P7_buf, P7_332, 6)!=0)
if (strncmp (P7_buf, P7_332, 6)!=0)
{
g_warning ("Thumbnail does not have the 'P7 332' header.");
fclose (fp);
@ -635,8 +630,8 @@ readXVThumb (const gchar *fnam,
do
{
ptr = fgets(linebuf, 199, fp);
if ((strncmp(linebuf, "#IMGINFO:", 9) == 0) &&
ptr = fgets (linebuf, 199, fp);
if ((strncmp (linebuf, "#IMGINFO:", 9) == 0) &&
(linebuf[9] != '\0') &&
(linebuf[9] != '\n'))
{
@ -646,7 +641,7 @@ readXVThumb (const gchar *fnam,
if (linebuf[9] != '\0')
{
if (*imginfo)
g_free(*imginfo);
g_free (*imginfo);
*imginfo = g_strdup (&linebuf[9]);
}
}
@ -660,7 +655,7 @@ readXVThumb (const gchar *fnam,
return NULL;
}
sscanf(linebuf, "%d %d %d\n", w, h, &twofivefive);
sscanf (linebuf, "%d %d %d\n", w, h, &twofivefive);
if (twofivefive!=255)
{

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
@ -47,25 +48,21 @@
#include "libgimp/gimpintl.h"
#ifndef G_OS_WIN32
# ifndef __EMX__
# define USER_INSTALL "user_install"
# else
# include <process.h>
# define USER_INSTALL "user_install.cmd"
# endif
#else
#ifdef G_OS_WIN32
# include <io.h>
# define mkdir(path, mode) _mkdir(path)
#endif
#define NUM_PAGES 6
#define EEK_PAGE (NUM_PAGES - 1)
#define PAGE_STYLE(widget) gtk_widget_modify_style (widget, page_style)
#define TITLE_STYLE(widget) gtk_widget_modify_style (widget, title_style)
enum {
enum
{
DIRENT_COLUMN,
PIXBUF_COLUMN,
DESC_COLUMN,
@ -933,203 +930,85 @@ user_install_dialog_create (const gchar *alternate_system_gimprc,
/*********************/
/* Local functions */
#ifdef G_OS_WIN32
static gchar *install_error_message;
static int
copy_file (gchar *source,
gchar *dest)
static gboolean
copy_file (gchar *source,
gchar *dest,
GError **error)
{
char buffer[4096];
FILE *sfile, *dfile;
int nbytes;
FILE *sfile;
FILE *dfile;
gchar buffer[4096];
gsize nbytes;
sfile = fopen (source, "rb");
if (sfile == NULL)
{
install_error_message = g_strdup_printf (_("Cannot open %s for reading"),
source);
return -1;
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot open '%s' for reading: %s"),
source, g_strerror (errno));
return FALSE;
}
dfile = fopen (dest, "wb");
if (dfile == NULL)
{
install_error_message = g_strdup_printf (_("Cannot open %s for writing"),
dest);
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot open '%s' for writing: %s"),
dest, g_strerror (errno));
fclose (sfile);
return -1;
return FALSE;
}
while ((nbytes = fread (buffer, 1, sizeof (buffer), sfile)) > 0)
{
if (fwrite (buffer, 1, nbytes, dfile) < nbytes)
{
install_error_message = g_strdup_printf (_("Error while writing %s"),
dest);
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error writing to '%s': %s"),
dest, g_strerror (errno));
fclose (sfile);
fclose (dfile);
return -1;
return FALSE;
}
}
if (ferror (sfile))
{
install_error_message = g_strdup_printf (_("Error while reading %s"),
source);
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Error reading from '%s': %s"),
source, g_strerror (errno));
fclose (sfile);
fclose (dfile);
return -1;
return FALSE;
}
fclose (sfile);
fclose (dfile);
return 0;
}
#endif
return TRUE;
}
static gboolean
user_install_run (void)
{
#ifndef G_OS_WIN32
FILE *pfp;
gchar *filename = NULL;
gchar *command = NULL;
struct stat stat_buf;
gint err;
gboolean executable = TRUE;
filename = g_build_filename (gimp_data_directory (), "misc",
USER_INSTALL, NULL);
if ((err = stat (filename, &stat_buf)) != 0)
{
gchar *str;
str = g_strdup_printf ("%s\n%s", filename,
_("does not exist. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
executable = FALSE;
}
#ifdef S_IXUSR
else if (! (S_IXUSR & stat_buf.st_mode) || ! (S_IRUSR & stat_buf.st_mode))
{
gchar *str;
str = g_strdup_printf ("%s\n%s", filename,
_("has invalid permissions. Cannot install."));
add_label (GTK_BOX (log_page), str);
g_free (str);
executable = FALSE;
}
#endif
if (executable)
{
#ifdef __EMX__
command = g_strdup_printf ("cmd.exe /c %s %s %s %s",
filename,
gimp_data_directory (),
gimp_directory (),
gimp_sysconf_directory());
{
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 (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),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (log_page), scrolled_window,
TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
log_buffer = gtk_text_buffer_new (NULL);
log_view = gtk_text_view_new_with_buffer (log_buffer);
g_object_unref (log_buffer);
PAGE_STYLE (log_view);
gtk_text_view_set_editable (GTK_TEXT_VIEW (log_view), FALSE);
gtk_container_add (GTK_CONTAINER (scrolled_window), log_view);
gtk_widget_show (log_view);
while (fgets (buffer, sizeof (buffer), pfp))
{
gtk_text_buffer_insert_at_cursor (log_buffer, buffer, -1);
}
pclose (pfp);
add_label (GTK_BOX (log_page),
_("Did you notice any error messages in the lines above?\n"
"If not, installation was successful!\n"
"Otherwise, quit and investigate the possible reason..."));
}
else
{
executable = FALSE;
}
}
g_free (command);
if (executable)
{
g_object_set_data (G_OBJECT (log_page), "footer",
_("Click \"Continue\" to complete GIMP installation."));
}
else
{
add_label (GTK_BOX (log_page),
_("Installation failed. Contact your system administrator."));
}
return executable;
#else
GtkWidget *scrolled_window;
GtkWidget *scrolled_window;
GtkTextBuffer *log_buffer;
GtkWidget *log_view;
gchar dest[1000];
gchar source[1000];
gchar log_line[1000];
gint i;
GtkWidget *log_view;
GError *error = NULL;
gchar dest[1000];
gchar source[1000];
gchar log_line[1000];
gint i;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (log_page), scrolled_window,
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (log_page), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show (scrolled_window);
log_buffer = gtk_text_buffer_new (NULL);
@ -1147,32 +1026,45 @@ user_install_run (void)
{
if (i == 0)
{
g_snprintf (log_line, sizeof (log_line), _("Creating folder %s\n"),
gimp_directory ());
g_snprintf (log_line, sizeof (log_line),
_("Creating folder %s\n"), gimp_directory ());
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
if (mkdir (gimp_directory (), 0666) == -1)
if (mkdir (gimp_directory (),
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH) == -1)
{
install_error_message = g_strdup_printf (_("Cannot create folder: %s"),
g_strerror (errno));
g_set_error (&error,
G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot create folder: %s"), g_strerror (errno));
goto break_out_of_loop;
}
gtk_text_buffer_insert_at_cursor (log_buffer, _(" Success\n"), -1);
}
g_snprintf (dest, sizeof (dest), "%s%c%s",
gimp_directory (), G_DIR_SEPARATOR, tree_items[i].text);
switch (tree_items[i].type)
{
case TREE_ITEM_DONT:
break;
case TREE_ITEM_MKDIR_ONLY:
g_snprintf (log_line, sizeof (log_line), _("Creating folder %s\n"),
dest);
g_snprintf (log_line, sizeof (log_line),
_("Creating folder %s\n"), dest);
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
if (mkdir (dest, 0666) == -1)
if (mkdir (dest,
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH) == -1)
{
install_error_message = g_strdup_printf (_("Cannot create folder: %s"),
g_strerror (errno));
g_set_error (&error,
G_FILE_ERROR, g_file_error_from_errno (errno),
_("Cannot create folder: %s"), g_strerror (errno));
goto break_out_of_loop;
}
break;
@ -1191,35 +1083,41 @@ user_install_run (void)
tree_items[i].source_filename : tree_items[i].text);
do_copy:
g_assert (!tree_items[i].directory);
g_snprintf (log_line, sizeof (log_line), _("Copying file %s from %s\n"),
dest, source);
g_snprintf (log_line, sizeof (log_line),
_("Copying file %s from %s\n"), dest, source);
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
if (copy_file (source, dest) == -1)
if (!copy_file (source, dest, &error))
goto break_out_of_loop;
break;
default:
g_assert_not_reached ();
break;
}
if (tree_items[i].type != TREE_ITEM_DONT)
gtk_text_buffer_insert_at_cursor (log_buffer, _(" Success\n"), -1);
}
break_out_of_loop:
if (i < num_tree_items)
if (error)
{
g_snprintf (log_line, sizeof (log_line), _(" Failure: %s\n"),
install_error_message);
error->message);
gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
add_label (GTK_BOX (log_page),
_("Installation failed. Contact system administrator."));
g_error_free (error);
return FALSE;
}
return TRUE;
#endif
}
static void

View File

@ -2,17 +2,11 @@
miscdatadir = $(gimpdatadir)/misc
miscdata_SCRIPTS = \
user_install
miscdata_in_files = gimp.desktop.in.in
miscdata_DATA = $(miscdata_in_files:.desktop.in.in=.desktop)
EXTRA_DIST = \
$(miscdata_SCRIPTS) \
gimp.desktop.in.in \
user_install.bat
EXTRA_DIST = gimp.desktop.in.in
gen_sources = desktop-foo
CLEANFILES = $(gen_sources)

View File

@ -1,58 +0,0 @@
#!/bin/sh
# Script to perform the default installation steps for the
# specified user home directory.
#
# 1) Create ~/.gimp-1.3 if it doesn't exist
# 2) Copy system gimprc file to ~/.gimp-1.3
# 3) Create brushes, gradients, palettes, patterns, plug-ins subdirs
# 4) Create the tmp subdirectory for disk-swapping undo buffers
#
echo "mkdir $2"
mkdir $2
echo "cp $3/unitrc $2/unitrc"
cp $3/unitrc $2/unitrc
echo "cp $3/gtkrc_user $2/gtkrc"
cp $3/gtkrc_user $2/gtkrc
echo "mkdir $2/themes"
mkdir $2/themes
echo "mkdir $2/brushes"
mkdir $2/brushes
echo "mkdir $2/gradients"
mkdir $2/gradients
echo "mkdir $2/palettes"
mkdir $2/palettes
echo "mkdir $2/patterns"
mkdir $2/patterns
echo "mkdir $2/plug-ins"
mkdir $2/plug-ins
echo "mkdir $2/modules"
mkdir $2/modules
echo "mkdir $2/environ"
mkdir $2/environ
echo "mkdir $2/scripts"
mkdir $2/scripts
echo "mkdir $2/tmp"
mkdir $2/tmp
echo "mkdir $2/curves"
mkdir $2/curves
echo "mkdir $2/levels"
mkdir $2/levels
echo "mkdir $2/fractalexplorer"
mkdir $2/fractalexplorer
echo "mkdir $2/gfig"
mkdir $2/gfig
echo "mkdir $2/gflare"
mkdir $2/gflare
echo "mkdir $2/gimpressionist"
mkdir $2/gimpressionist
echo "mkdir $2/gimpressionist/Brushes"
mkdir $2/gimpressionist/Brushes
echo "mkdir $2/gimpressionist/Paper"
mkdir $2/gimpressionist/Paper
echo "mkdir $2/gimpressionist/Presets"
mkdir $2/gimpressionist/Presets

View File

@ -1,25 +0,0 @@
@REM This file is executed by the GIMP. Do NOT run this yourself.
@echo off
mkdir %2
copy %3\gimprc_user %2\gimprc
copy %3\unitrc %2\unitrc
copy %3\gtkrc_user %2\gtkrc
mkdir %2\themes
mkdir %2\brushes
mkdir %2\gradients
mkdir %2\palettes
mkdir %2\patterns
mkdir %2\plug-ins
mkdir %2\modules
mkdir %2\scripts
mkdir %2\gfig
mkdir %2\gflare
mkdir %2\fractalexplorer
mkdir %2\gimpressionist
mkdir %2\gimpressionist\Brushes
mkdir %2\gimpressionist\Paper
mkdir %2\gimpressionist\Presets
mkdir %2\levels
mkdir %2\curves
pause