• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

parsing bin/ls for ftp -- knowing dir link vs file linked

michaelh20

Senior member
When an FTP program needs to know when a linked file is directory or file, is this possible?

For example :
-rw-r--r-- 1 hoff0103 student 5454 May 15 15:36 stuff2.txt
lrwxrwxrwx 1 hoff0103 student 24 Aug 2 2001 web-docs -> /www/h/hoff0103/web-docs

How can a program know that web-docs is a directory (it is a dir) and not a file?


I don't see a way to this outside of looking at extensions and guessing that certain extensions = a File...
Naturally, could try to retrieve or to CD to that link and see what happens, but this would be a bit painful, if this had to happen lots of times to figure out a whole dir list.
 
Since unix isn't tied to file extensions like Windows is the only real way to know for sure is to investigate the target file, normally this would be a stat() system call to get it's attributes and see if it's normal or a directory, through FTP cwd would probably be the easiest.
 
Back
Top