DaemonEngine / crunch

Advanced DXTc texture compression and transcoding library and tool, upgraded with Unity improvements, added features, extended system and hardware support, deeply tested.
https://github.com/DaemonEngine/crunch
Other
16 stars 6 forks source link

crnlib: correct alternate code to test if a path is a directory #64

Closed illwieckz closed 4 months ago

illwieckz commented 4 months ago

The alternate code was testing for the file name in the current directory.

Fixes #63:

illwieckz commented 4 months ago

One may open the folder with open then use fstatat on the file name to avoid concatenating a string, but we better assume doing an extra IO is slower than string concatenation.

illwieckz commented 4 months ago

Also an alternate code to use open on the parent dir to then use fdopendir instead of opendir to then reuse the fd with fstatat is not possible as the man page says:

After a successful call to fdopendir(), fd is used internally by the implemen‐ tation, and should not otherwise be used by the application.

So this may be the fastest code.