This is a seemingly simple question however I could not find a satisfactory solution yet.
let f = FileInfo(e)
let fileFlag = f.Attributes.HasFlag(FileAttributes.Normal)
logger <| sprintf "%s :: %A :: %A" e fileFlag f.Attributes
This produces the following output:
/tmp/com.apple.launchd.qq7qSI6dyD/Listeners :: true :: Normal
To my surprise the path is a socket:
> file /tmp/com.apple.launchd.qq7qSI6dyD/Listeners
/tmp/com.apple.launchd.qq7qSI6dyD/Listeners: socket
According to the FileAttributes Enum documentation:
Normal 128
The file is a standard file that has no special attributes. This attribute is valid only if it is used alone.
Normal
is supported on Windows, Linux, and macOS.
Is there a way to check is a path really a normal file (not a socket, not a symlink, not a device, etc.).
For example in Python:
> python -c "import os; import sys; print(os.path.isfile(sys.argv[1]))"
/tmp/com.apple.launchd.qq7qSI6dyD/Listeners
False
Elaborating more:
> stat -f "%N: %HT%SY" /tmp/**/*
/tmp/b: Symbolic Link -> a
/tmp/com.apple.launchd.qq7qSI6dyD: Directory
/tmp/com.apple.launchd.qq7qSI6dyD/Listeners: Socket
/tmp/fseventsd-uuid: Regular File
/tmp/powerlog: Directory
/tmp/test: Regular File
/tmp/tmux-501: Directory
/tmp/tmux-501/default: Socket