[glib/glib-2-22] Make g_file_test() behave on Windows more like as on POSIX
- From: Tor Lillqvist <tml src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/glib-2-22] Make g_file_test() behave on Windows more like as on POSIX
- Date: Tue, 3 Nov 2009 12:33:12 +0000 (UTC)
commit 0f5d8b4cbae7e89b79245914f7b22ed38e9455a8
Author: Carlo Bramini <carlo bramix libero it>
Date: Tue Nov 3 14:26:25 2009 +0200
Make g_file_test() behave on Windows more like as on POSIX
Patch from bug #572252.
glib/gfileutils.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index fcbd63b..3633753 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -204,19 +204,26 @@ g_file_test (const gchar *filename,
return TRUE;
if (test & G_FILE_TEST_IS_REGULAR)
- return (attributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0;
+ {
+ if ((attributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0)
+ return TRUE;
+ }
if (test & G_FILE_TEST_IS_DIR)
- return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
+ {
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ return TRUE;
+ }
- if (test & G_FILE_TEST_IS_EXECUTABLE)
+ /* "while" so that we can exit this "loop" with a simple "break" */
+ while (test & G_FILE_TEST_IS_EXECUTABLE)
{
const gchar *lastdot = strrchr (filename, '.');
const gchar *pathext = NULL, *p;
int extlen;
if (lastdot == NULL)
- return FALSE;
+ break;
if (_stricmp (lastdot, ".exe") == 0 ||
_stricmp (lastdot, ".cmd") == 0 ||
@@ -228,7 +235,7 @@ g_file_test (const gchar *filename,
pathext = g_getenv ("PATHEXT");
if (pathext == NULL)
- return FALSE;
+ break;
pathext = g_utf8_casefold (pathext, -1);
@@ -256,7 +263,7 @@ g_file_test (const gchar *filename,
g_free ((gchar *) pathext);
g_free ((gchar *) lastdot);
- return FALSE;
+ break;
}
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]