Revision: 4925 http://geany.svn.sourceforge.net/geany/?rev=4925&view=rev Author: eht16 Date: 2010-05-16 17:44:51 +0000 (Sun, 16 May 2010)
Log Message: ----------- Implement reading and evaluating hidden file attribute on Windows.
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/filebrowser.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-05-16 17:44:40 UTC (rev 4924) +++ trunk/ChangeLog 2010-05-16 17:44:51 UTC (rev 4925) @@ -18,6 +18,8 @@ src/makefile.win32: Add new GTK define also for Mingw cross compilation and 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>
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2010-05-16 17:44:40 UTC (rev 4924) +++ trunk/plugins/filebrowser.c 2010-05-16 17:44:51 UTC (rev 4925) @@ -29,6 +29,9 @@
#include <gdk/gdkkeysyms.h>
+#ifdef G_OS_WIN32 +# include <windows.h> +#endif
GeanyPlugin *geany_plugin; GeanyData *geany_data; @@ -99,16 +102,35 @@ };
+#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. */ -static gboolean check_hidden(const gchar *base_name) +static gboolean check_hidden(const gchar *filename, const gchar *base_name) { gsize len;
if (! NZV(base_name)) return FALSE;
+#ifdef G_OS_WIN32 + if (win32_check_hidden(filename)) + return TRUE; +#else if (base_name[0] == '.') return TRUE; +#endif
len = strlen(base_name); if (base_name[len - 1] == '~') @@ -154,9 +176,6 @@ const gchar *sep; gboolean dir;
- if (! show_hidden_files && check_hidden(name)) - return; - sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S; fname = g_strconcat(current_dir, sep, name, NULL); dir = g_file_test(fname, G_FILE_TEST_IS_DIR); @@ -164,6 +183,13 @@ utf8_name = utils_get_utf8_from_locale(name); g_free(fname);
+ if (! show_hidden_files && check_hidden(utf8_fullname, name)) + { + g_free(utf8_name); + g_free(utf8_fullname); + return; + } + if (dir) { if (last_dir_iter == NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.