Do not follow symbolic links for G_FILE_TEST_SYMLINK. Also fixed the

2002-02-07  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* glib/gfileutils.c (g_file_test): Do not follow symbolic links
	for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
	G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
This commit is contained in:
Sebastian Wilhelmi 2002-02-07 20:14:00 +00:00 committed by Sebastian Wilhelmi
parent a1c162e123
commit eb18855127
9 changed files with 77 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -1,3 +1,9 @@
2002-02-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gfileutils.c (g_file_test): Do not follow symbolic links
for G_FILE_TEST_SYMLINK. Also fixed the correct "OR"-behaviour for
G_FILE_TEST_IS_EXECUTABLE and G_FILE_TEST_EXISTS. (#60048)
2002-02-07 Changwoo Ryu <cwryu@debian.org>
* configure.in (ALL_LINGUAS): Added "ko".

View File

@ -76,6 +76,10 @@
* the check whether it's a directory doesn't matter since the existence
* test is %TRUE. With the current set of available tests, there's no point
* passing in more than one test at a time.
*
* Apart from #G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
* so for a symbolic link to a regular file g_file_test() will return
* %TRUE for both #G_FILE_TEST_IS_SYMLINK and #G_FILE_TEST_IS_REGULAR.
*
* Return value: whether a test was %TRUE
**/
@ -83,29 +87,35 @@ gboolean
g_file_test (const gchar *filename,
GFileTest test)
{
if (test & G_FILE_TEST_EXISTS)
return (access (filename, F_OK) == 0);
else if (test & G_FILE_TEST_IS_EXECUTABLE)
return (access (filename, X_OK) == 0);
else
if ((test & G_FILE_TEST_EXISTS) && (access (filename, F_OK) == 0))
return TRUE;
if ((test & G_FILE_TEST_IS_EXECUTABLE) && (access (filename, X_OK) == 0))
return TRUE;
if (test & G_FILE_TEST_IS_SYMLINK)
{
struct stat s;
if ((lstat (filename, &s) == 0) && S_ISLNK (s.st_mode))
return TRUE;
}
if (test & (G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_DIR))
{
struct stat s;
if (stat (filename, &s) < 0)
return FALSE;
if ((test & G_FILE_TEST_IS_REGULAR) &&
S_ISREG (s.st_mode))
return TRUE;
else if ((test & G_FILE_TEST_IS_DIR) &&
S_ISDIR (s.st_mode))
return TRUE;
else if ((test & G_FILE_TEST_IS_SYMLINK) &&
S_ISLNK (s.st_mode))
return TRUE;
else
return FALSE;
if (stat (filename, &s) == 0)
{
if ((test & G_FILE_TEST_IS_REGULAR) && S_ISREG (s.st_mode))
return TRUE;
if ((test & G_FILE_TEST_IS_DIR) && S_ISDIR (s.st_mode))
return TRUE;
}
}
return FALSE;
}
GQuark