Eina: add eina_file_access() API #56
Loading…
Reference in New Issue
No description provided.
Delete Branch "vtorri/efl:vtorri_eina_file_access"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
this addition is motivated by the fact that the access() API on
Windows just check if a file is read only or read/write. See
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=msvc-170#remarks
This API now also manage if a file/dir is executable or not.
On Unix, access() is just called.
Hmmm. This implements something neat - actually checking it's a real executable file in the file itself.. but that's not what access() does. access()just checks the file claims at the metadata level (file mode bits) to e.g. be executable. It may have +x set but may not actually work if it's not an ELF executable or valid shell + interpreter script. In fact on Linux it could even be a .java file or something else if you have a misc binary emulator registered.
so what you've implemented is not access(). it's something very different. it's closer to efreet's mime checking that checks the binary signature of the file for mime type. it's expensive to open a file and start reading it to get bytes compared to just checking mode bits.
i don't think the implementation here is useful as a replacement for access(). it's more useful to make efreet and its mime checking work on windows (and provide a mime + byte magic database) and then it can tell you any type of file regardless of extn.
otherwise i think the implementation here probably should be a lot simpler on windows. check its a *.exe, *.con etc.file (anything you could just double-click on to run) so a "check for extension" is probably the cheap/fast equivalent of mode bits on unix for +x. so i think move to that then it's equivalently fast/cheap
@raster now, with the directory "c:\Windows\System32\WDI", that I can't see with the file explorer (i double click, nothing happens), without the CreateFile() that I removed, i can't detect this. Should I re-add CreateFile() for directories ?
@raster also have the enum values a good name ?