mirror of https://github.com/GNOME/gimp.git
move private functions to the end of the file. Added function is_hidden()
2007-09-14 Michael Natterer <mitch@gimp.org> * libgimpbase/gimpdatafiles.c: move private functions to the end of the file. Added function is_hidden() and use it in gimp_datafiles_read_directories(). Moved variables to local scopes. svn path=/trunk/; revision=23547
This commit is contained in:
parent
3073cf88fe
commit
8e86bc46f9
|
@ -1,3 +1,10 @@
|
|||
2007-09-14 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpbase/gimpdatafiles.c: move private functions to the end
|
||||
of the file. Added function is_hidden() and use it in
|
||||
gimp_datafiles_read_directories(). Moved variables to local
|
||||
scopes.
|
||||
|
||||
2007-09-14 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gui/gui-vtable.c (gui_recent_list_add_uri): use the
|
||||
|
|
|
@ -43,50 +43,11 @@
|
|||
#include "gimpenv.h"
|
||||
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/*
|
||||
* On Windows there is no concept like the Unix executable flag.
|
||||
* 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.
|
||||
*/
|
||||
static gboolean
|
||||
is_script (const gchar *filename)
|
||||
{
|
||||
static gchar **exts = NULL;
|
||||
static inline gboolean is_script (const gchar *filename);
|
||||
static inline gboolean is_hidden (const gchar *filename);
|
||||
|
||||
const gchar *ext = strrchr (filename, '.');
|
||||
gchar *pathext;
|
||||
gint i;
|
||||
|
||||
if (exts == NULL)
|
||||
{
|
||||
pathext = g_getenv ("PATHEXT");
|
||||
if (pathext != NULL)
|
||||
{
|
||||
exts = g_strsplit (pathext, G_SEARCHPATH_SEPARATOR_S, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
exts = g_new (gchar *, 1);
|
||||
exts[0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (exts[i] != NULL)
|
||||
{
|
||||
if (g_ascii_strcasecmp (ext, exts[i]) == 0)
|
||||
return TRUE;
|
||||
i++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#else /* !G_OS_WIN32 */
|
||||
#define is_script(filename) FALSE
|
||||
#endif
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
gimp_datafiles_check_extension (const gchar *filename,
|
||||
|
@ -137,30 +98,25 @@ gimp_datafiles_read_directories (const gchar *path_str,
|
|||
|
||||
while ((dir_ent = g_dir_read_name (dir)))
|
||||
{
|
||||
GimpDatafileData file_data;
|
||||
struct stat filestat;
|
||||
gchar *filename;
|
||||
gint err;
|
||||
struct stat filestat;
|
||||
gchar *filename;
|
||||
|
||||
/* skip files starting with '.' so we don't try to parse
|
||||
* stuff like .DS_Store or other metadata storage files
|
||||
*/
|
||||
if (dir_ent[0] == '.')
|
||||
if (is_hidden (dir_ent))
|
||||
continue;
|
||||
|
||||
filename = g_build_filename (dirname, dir_ent, NULL);
|
||||
|
||||
err = g_stat (filename, &filestat);
|
||||
|
||||
file_data.filename = filename;
|
||||
file_data.dirname = dirname;
|
||||
file_data.basename = dir_ent;
|
||||
file_data.atime = filestat.st_atime;
|
||||
file_data.mtime = filestat.st_mtime;
|
||||
file_data.ctime = filestat.st_ctime;
|
||||
|
||||
if (! err)
|
||||
if (! g_stat (filename, &filestat))
|
||||
{
|
||||
GimpDatafileData file_data;
|
||||
|
||||
file_data.filename = filename;
|
||||
file_data.dirname = dirname;
|
||||
file_data.basename = dir_ent;
|
||||
file_data.atime = filestat.st_atime;
|
||||
file_data.mtime = filestat.st_mtime;
|
||||
file_data.ctime = filestat.st_ctime;
|
||||
|
||||
if (flags & G_FILE_TEST_EXISTS)
|
||||
{
|
||||
(* loader_func) (&file_data, user_data);
|
||||
|
@ -202,3 +158,60 @@ gimp_datafiles_read_directories (const gchar *path_str,
|
|||
gimp_path_free (path);
|
||||
g_free (local_path);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static inline gboolean
|
||||
is_script (const gchar *filename)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
/* On Windows there is no concept like the Unix executable flag.
|
||||
* 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.
|
||||
*/
|
||||
static gchar **exts = NULL;
|
||||
|
||||
const gchar *ext = strrchr (filename, '.');
|
||||
gchar *pathext;
|
||||
gint i;
|
||||
|
||||
if (exts == NULL)
|
||||
{
|
||||
pathext = g_getenv ("PATHEXT");
|
||||
if (pathext != NULL)
|
||||
{
|
||||
exts = g_strsplit (pathext, G_SEARCHPATH_SEPARATOR_S, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
exts = g_new (gchar *, 1);
|
||||
exts[0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (exts[i] != NULL)
|
||||
{
|
||||
if (g_ascii_strcasecmp (ext, exts[i]) == 0)
|
||||
return TRUE;
|
||||
i++;
|
||||
}
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_hidden (const gchar *filename)
|
||||
{
|
||||
/* skip files starting with '.' so we don't try to parse
|
||||
* stuff like .DS_Store or other metadata storage files
|
||||
*/
|
||||
if (filename[0] == '.')
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue