From daf89b29a3ef37c272394cba3929290f2980a421 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Fri, 22 Jan 2021 23:55:03 -0500 Subject: started auto-cd --- filesystem-posix.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'filesystem-posix.c') 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)) -- cgit v1.2.3