summaryrefslogtreecommitdiff
path: root/filesystem-posix.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-22 23:55:03 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-22 23:55:03 -0500
commitdaf89b29a3ef37c272394cba3929290f2980a421 (patch)
tree866d05a76975111b35dd92997f54bc510f4d73d1 /filesystem-posix.c
parent8da3cb956b14a7644f815a1874bdcf29a4cb711d (diff)
started auto-cd
Diffstat (limited to 'filesystem-posix.c')
-rw-r--r--filesystem-posix.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/filesystem-posix.c b/filesystem-posix.c
index ebf1407..cf4a04b 100644
--- a/filesystem-posix.c
+++ b/filesystem-posix.c
@@ -7,8 +7,15 @@
FsType fs_path_type(char const *path) {
struct stat statbuf = {0};
+ char linkbuf[8];
+ if (readlink(path, linkbuf, sizeof linkbuf) != -1) {
+ // unfortunately there is no way of telling from stat alone whether a directory is a symbolic link >:(
+ return FS_LINK;
+ }
if (stat(path, &statbuf) != 0)
return FS_NON_EXISTENT;
+ if (S_ISLNK(statbuf.st_mode))
+ return FS_LINK;
if (S_ISREG(statbuf.st_mode))
return FS_FILE;
if (S_ISDIR(statbuf.st_mode))