summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Barker <paul@paulbarker.me.uk>2014-02-16 18:26:48 (EST)
committer Paul Barker <paul@paulbarker.me.uk>2014-03-18 08:35:07 (EDT)
commit8c438cacdfa3742922f94f81d756383e71d49226 (patch)
treea3036a072206372940f6ca7558d6110cf2976479
parentb634d68b94652470582a11a3406ebaf7cf34b9e5 (diff)
file_util: Add file_is_symlink function
This function should be pretty self explanatory Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
-rw-r--r--libopkg/file_util.c11
-rw-r--r--libopkg/file_util.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/libopkg/file_util.c b/libopkg/file_util.c
index 897546e..82578bd 100644
--- a/libopkg/file_util.c
+++ b/libopkg/file_util.c
@@ -55,6 +55,17 @@ file_is_dir(const char *file_name)
return S_ISDIR(st.st_mode);
}
+int
+file_is_symlink(const char *file_name)
+{
+ struct stat st;
+
+ if (lstat(file_name, &st) == -1)
+ return 0;
+
+ return S_ISLNK(st.st_mode);
+}
+
/* read a single line from a file, stopping at a newline or EOF.
If a newline is read, it will appear in the resulting string.
Return value is a malloc'ed char * which should be freed at
diff --git a/libopkg/file_util.h b/libopkg/file_util.h
index d4ae05f..f4a9b75 100644
--- a/libopkg/file_util.h
+++ b/libopkg/file_util.h
@@ -24,6 +24,7 @@ extern "C" {
int file_exists(const char *file_name);
int file_is_dir(const char *file_name);
+int file_is_symlink(const char *file_name);
char *file_read_line_alloc(FILE *file);
int file_move(const char *src, const char *dest);
int file_copy(const char *src, const char *dest);