Kaydet (Commit) aa05d3be authored tarafından Enrico Tröger's avatar Enrico Tröger

Implement reading and evaluating hidden file attribute on Windows.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4925 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 8c865b68
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
src/makefile.win32: src/makefile.win32:
Add new GTK define also for Mingw cross compilation and Add new GTK define also for Mingw cross compilation and
makefile.win32 based Windows builds. makefile.win32 based Windows builds.
* plugins/filebrowser.c:
Implement reading and evaluating hidden file attribute on Windows.
2010-05-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> 2010-05-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
......
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#ifdef G_OS_WIN32
# include <windows.h>
#endif
GeanyPlugin *geany_plugin; GeanyPlugin *geany_plugin;
GeanyData *geany_data; GeanyData *geany_data;
...@@ -99,16 +102,35 @@ PluginCallback plugin_callbacks[] = ...@@ -99,16 +102,35 @@ PluginCallback plugin_callbacks[] =
}; };
#ifdef G_OS_WIN32
static gboolean win32_check_hidden(const gchar *filename)
{
DWORD attrs;
static wchar_t w_filename[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename));
attrs = GetFileAttributesW(w_filename);
if (attrs != INVALID_FILE_ATTRIBUTES && attrs & FILE_ATTRIBUTE_HIDDEN)
return TRUE;
return FALSE;
}
#endif
/* Returns: whether name should be hidden. */ /* Returns: whether name should be hidden. */
static gboolean check_hidden(const gchar *base_name) static gboolean check_hidden(const gchar *filename, const gchar *base_name)
{ {
gsize len; gsize len;
if (! NZV(base_name)) if (! NZV(base_name))
return FALSE; return FALSE;
#ifdef G_OS_WIN32
if (win32_check_hidden(filename))
return TRUE;
#else
if (base_name[0] == '.') if (base_name[0] == '.')
return TRUE; return TRUE;
#endif
len = strlen(base_name); len = strlen(base_name);
if (base_name[len - 1] == '~') if (base_name[len - 1] == '~')
...@@ -154,9 +176,6 @@ static void add_item(const gchar *name) ...@@ -154,9 +176,6 @@ static void add_item(const gchar *name)
const gchar *sep; const gchar *sep;
gboolean dir; gboolean dir;
if (! show_hidden_files && check_hidden(name))
return;
sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S; sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S;
fname = g_strconcat(current_dir, sep, name, NULL); fname = g_strconcat(current_dir, sep, name, NULL);
dir = g_file_test(fname, G_FILE_TEST_IS_DIR); dir = g_file_test(fname, G_FILE_TEST_IS_DIR);
...@@ -164,6 +183,13 @@ static void add_item(const gchar *name) ...@@ -164,6 +183,13 @@ static void add_item(const gchar *name)
utf8_name = utils_get_utf8_from_locale(name); utf8_name = utils_get_utf8_from_locale(name);
g_free(fname); g_free(fname);
if (! show_hidden_files && check_hidden(utf8_fullname, name))
{
g_free(utf8_name);
g_free(utf8_fullname);
return;
}
if (dir) if (dir)
{ {
if (last_dir_iter == NULL) if (last_dir_iter == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment