I am trying to make a simple program that handles files and directories, but I have two major problems:
- how can I check whether a file or directory exists or not, and
- how do I know if it is a file, directory, symbolic link, device, named pipe etc.? Mainly file and directories matter for now, but I’d like to know the others too.
EDIT: Too all of those who are suggesting to use stat() or a similar function, I have already looked into that, and while it might answer my first question, I can’t figure out how it would answer the second…
Since you’re inquiring about named pipes/symlinks etc, you’re probably on *nix, so use the
lstat() function
Se docs here for the S_ISXXX macros you can use.