I am making a CLI utility using PHP that will run on Windows and Linux, and I need to check whether a specified file is a device file.
I've had a look at How to guarantee a specified file is a device on BSD/Linux from PHP? but none of the approaches worked on multiple OSes.
How to approach this in a functional way?
On Linux stat()
works on most files, but I don't know how to differentiate device vs regular files.
Running stat("con")
on Windows returns an error whereas stat("nul")
does not.