Eina: add eina_file_access() API #56

Merged
raster merged 2 commits from vtorri/efl:vtorri_eina_file_access into master 2024-03-25 10:18:48 -07:00
Owner

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.

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.
vtorri added 1 commit 2024-01-17 19:00:51 -08:00
34e25ac568 Eina: add eina_file_access() API
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.
Owner

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

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
vtorri added 1 commit 2024-03-19 15:23:31 -07:00
Author
Owner

@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 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 ?
Author
Owner

@raster also have the enum values a good name ?

@raster also have the enum values a good name ?
raster approved these changes 2024-03-25 10:18:29 -07:00
raster merged commit a6915ecfc5 into master 2024-03-25 10:18:48 -07:00
raster deleted branch vtorri_eina_file_access 2024-03-25 10:18:52 -07:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: enlightenment/efl#56
No description provided.