reactphp / filesystem

Evented filesystem access.
MIT License
135 stars 40 forks source link

file()->stat() not working as expected when file is symlink #68

Open gizahNL opened 5 years ago

gizahNL commented 5 years ago

I'm using dir()->ls() to create an array of nodes which I then stat, unfortunately stat() does not work as expected on symlinks: it returns the size of the symlink file (and not the target), and does not hint it is a symlink. Neither does the nodelist ls() generates hint any of the files are symlinks: when I echo the class they are all File class.

multiple different solutions exist: -ls() returns different nodes for files and links

-the file node has an isLink method, returning true or false

-hide the fact that the file is a symlink completely and return properties of target

-return an islink value (with target) when doing stat()

ghost commented 5 years ago

stat calls lstat internally, which does not resolve symlink. That's working as intended as we should be able to stat symlinks and not only files.

The problem with ls not returning Links sounds like a bug to me. Which adapter do you use? Eio or child process (just var_dump the adapter if you use Filesystem::create())?

WyriHaximus commented 5 years ago

The problem with ls not returning Links sounds like a bug to me. Which adapter do you use? Eio or child process (just var_dump the adapter if you use Filesystem::create())?

Indeed, a symlink should show up as a Link not a File. What OS/PHP version/adapter/and extensions are you on @gizahNL ?