libgimp/gimp.def libgimp/gimpui.def libgimp/makefile.{cygwin,msc}
2000-02-15 Tor Lillqvist <tml@iki.fi> * libgimp/gimp.def * libgimp/gimpui.def * libgimp/makefile.{cygwin,msc} * app/makefile.{cygwin,msc} * plug-ins/makefile.{cygwin,msc}: Updates. * app/datafiles.c (is_script): New Win32-only function, which tests if a file's extension matches one of the extensions in the PATHEXT environment variable (which the cmd.exe command interpreter also uses). This is to avoid starting applications associated with any random data file the user might have dropped in the plug-ins folder, while still supporting plug-ins written in scripting languages. * app/gimpparasite.c (gimp_parasiterc_save): (Win32:) Cannot rename to an existing file. * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_share.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c: Use G_PI. * plug-ins/common/gz.c: #ifdef G_OS_WIN32 was used before its potential definition via glib.h. * plug-ins/common/jpeg.c: Also recognize Exif files, which are typically produced by digital cameras. The usually have a .jpg file name extension, and would thus already match this plug-in, but add the magic string just in case. They are loaded just fine by libjpeg even if they don't have the JFIF signature. * plug-ins/common/tiff.c: Set TIFF warning and error handler, so we get to pass libtiff's messages through the normal channels.
This commit is contained in:
committed by
Tor Lillqvist
parent
5dfe4f08f5
commit
970ad834d1
@ -39,9 +39,9 @@
|
||||
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
||||
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||
#endif
|
||||
/* (Re)define S_IXUSR as _S_IREAD to get scripts, too. */
|
||||
#undef S_IXUSR
|
||||
#define S_IXUSR _S_IREAD
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR _S_IEXEC
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
#include "datafiles.h"
|
||||
@ -57,6 +57,51 @@
|
||||
static int filestat_valid = 0;
|
||||
static struct stat filestat;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/*
|
||||
* On Windows there is no concept like the Unix executable flag. There
|
||||
* There is a weak emulation provided by the MS C Runtime using file
|
||||
* extensions (com, exe, cmd, bat). This needs to be extended to treat
|
||||
* scripts (Python, Perl, ...) as executables, too. We use the PATHEXT
|
||||
* variable, which is also used by cmd.exe.
|
||||
*/
|
||||
gboolean
|
||||
is_script (const gchar* filename)
|
||||
{
|
||||
const gchar *ext = strrchr (filename, '.');
|
||||
gchar *pathext;
|
||||
static gchar **exts = NULL;
|
||||
gint i;
|
||||
|
||||
if (exts == NULL)
|
||||
{
|
||||
pathext = g_getenv ("PATHEXT");
|
||||
if (pathext != NULL)
|
||||
{
|
||||
exts = g_strsplit (pathext, G_SEARCHPATH_SEPARATOR_S, 100);
|
||||
g_free (pathext);
|
||||
}
|
||||
else
|
||||
{
|
||||
exts = g_new (gchar *, 1);
|
||||
exts[0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (exts[i] != NULL)
|
||||
{
|
||||
if (g_strcasecmp (ext, exts[i]) == 0)
|
||||
return TRUE;
|
||||
i++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#else /* !G_OS_WIN32 */
|
||||
#define is_script(filename) FALSE
|
||||
#endif
|
||||
|
||||
void
|
||||
datafiles_read_directories (char *path_str,
|
||||
datafile_loader_t loader_func,
|
||||
@ -131,7 +176,9 @@ datafiles_read_directories (char *path_str,
|
||||
err = stat(filename, &filestat);
|
||||
|
||||
if (!err && S_ISREG(filestat.st_mode) &&
|
||||
(!(flags & MODE_EXECUTABLE) || (filestat.st_mode & S_IXUSR)))
|
||||
(!(flags & MODE_EXECUTABLE) ||
|
||||
(filestat.st_mode & S_IXUSR) ||
|
||||
is_script (filename)))
|
||||
{
|
||||
filestat_valid = 1;
|
||||
(*loader_func) (filename);
|
||||
|
||||
Reference in New Issue
Block a user