summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/lib/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_install/lib/file.c')
-rw-r--r--usr.sbin/pkg_install/lib/file.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 49db198..a54df9e 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -40,7 +40,7 @@ fexists(char *fname)
return FALSE;
}
-/* Quick check to see if something is a directory */
+/* Quick check to see if something is a directory or symlink to a directory */
Boolean
isdir(char *fname)
{
@@ -54,7 +54,7 @@ isdir(char *fname)
return FALSE;
}
-/* Check to see if file is a dir, and is empty */
+/* Check to see if file is a dir or symlink to a dir, and is empty */
Boolean
isemptydir(char *fname)
{
@@ -77,6 +77,10 @@ isemptydir(char *fname)
return FALSE;
}
+/*
+ * Returns TRUE if file is a regular file or symlink pointing to a regular
+ * file
+ */
Boolean
isfile(char *fname)
{
@@ -86,8 +90,11 @@ isfile(char *fname)
return FALSE;
}
-/* Check to see if file is a file and is empty. If nonexistent or not
- a file, say "it's empty", otherwise return TRUE if zero sized. */
+/*
+ * Check to see if file is a file or symlink pointing to a file and is empty.
+ * If nonexistent or not a file, say "it's empty", otherwise return TRUE if
+ * zero sized.
+ */
Boolean
isemptyfile(char *fname)
{
@@ -99,6 +106,16 @@ isemptyfile(char *fname)
return TRUE;
}
+/* Returns TRUE if file is a symbolic link. */
+Boolean
+issymlink(char *fname)
+{
+ struct stat sb;
+ if (lstat(fname, &sb) != FAIL && S_ISLNK(sb.st_mode))
+ return TRUE;
+ return FALSE;
+}
+
/* Returns TRUE if file is a URL specification */
Boolean
isURL(char *fname)
OpenPOWER on IntegriCloud