Closed emoon closed 9 years ago
Maybe add another function called library_load_fullname/fullpath or something like that where the user has to provide a fully formated path instead.
Of course it's your library so you do as you wish of course :)
Good catch, that particular code is an migration from another codebase and some legacy got included. Will clean it up.
Thanks :)
I've cleaned up the fallback, which makes sense in that the idea is to be able to call library_load( "foo" ) without having to worry about platform specific prefix/suffix.
The fallback now only triggers if the platform extension is not present, and the fallback adds the prefix/suffix on the file name, preserving paths. It always tries to load the given name first, unmodified.
Check out https://github.com/rampantpixels/foundation_lib/tree/feature/library-load and see if you agree it's a reasonable implementation
Looks good. Something that might be worth considering checking is for backslashes in the path here (on Windows) https://github.com/rampantpixels/foundation_lib/blob/feature/library-load/foundation/library.c#L100
I really don't use that myself but I can see that other people will.
Merged in 8194e3babb
Tested this now and works as expected. Thanks!
Might be good to add some more tests to validate the code (as you already have really good tests for most of the code)
When using
The code assumes that there is no path in the in the name being sent in. The code will expand the string to look like this (on Mac)
Which means that the current code always adds "lib" at the start regardless if there is a directory there or not.