mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-23 17:38:54 +02:00
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:
committed by
Sebastian Wilhelmi
parent
a1c162e123
commit
eb18855127
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -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>
|
2002-02-07 Changwoo Ryu <cwryu@debian.org>
|
||||||
|
|
||||||
* configure.in (ALL_LINGUAS): Added "ko".
|
* configure.in (ALL_LINGUAS): Added "ko".
|
||||||
|
@@ -76,6 +76,10 @@
|
|||||||
* the check whether it's a directory doesn't matter since the existence
|
* 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
|
* test is %TRUE. With the current set of available tests, there's no point
|
||||||
* passing in more than one test at a time.
|
* 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
|
* Return value: whether a test was %TRUE
|
||||||
**/
|
**/
|
||||||
@@ -83,29 +87,35 @@ gboolean
|
|||||||
g_file_test (const gchar *filename,
|
g_file_test (const gchar *filename,
|
||||||
GFileTest test)
|
GFileTest test)
|
||||||
{
|
{
|
||||||
if (test & G_FILE_TEST_EXISTS)
|
if ((test & G_FILE_TEST_EXISTS) && (access (filename, F_OK) == 0))
|
||||||
return (access (filename, F_OK) == 0);
|
return TRUE;
|
||||||
else if (test & G_FILE_TEST_IS_EXECUTABLE)
|
|
||||||
return (access (filename, X_OK) == 0);
|
if ((test & G_FILE_TEST_IS_EXECUTABLE) && (access (filename, X_OK) == 0))
|
||||||
else
|
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;
|
struct stat s;
|
||||||
|
|
||||||
if (stat (filename, &s) < 0)
|
if (stat (filename, &s) == 0)
|
||||||
return FALSE;
|
{
|
||||||
|
if ((test & G_FILE_TEST_IS_REGULAR) && S_ISREG (s.st_mode))
|
||||||
if ((test & G_FILE_TEST_IS_REGULAR) &&
|
return TRUE;
|
||||||
S_ISREG (s.st_mode))
|
|
||||||
return TRUE;
|
if ((test & G_FILE_TEST_IS_DIR) && S_ISDIR (s.st_mode))
|
||||||
else if ((test & G_FILE_TEST_IS_DIR) &&
|
return TRUE;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GQuark
|
GQuark
|
||||||
|
Reference in New Issue
Block a user