Hi!
As the title says: Is there a convenient way to obtain the filename only (including file extension) out of an ALLEGRO_FS_ENTRY? Let's say I have a file associated with an ALLEGRO_FS_ENTRY named 'myfile' then I can use al_get_fs_entry_name(myfile) to obtain the full path+filename+extension. Of course I could iterate through this string backwards until I find a '/' and copy the difference but I am wondering if there is an easier or built-in function for that...
You're giving me the lulz man.
std::string GetFileName(std::string path) { unsigned int slash = path.find_last_of("\/"); if (slash == std::string::npos) {return path;} return path.substr(slash); }
I think you need to go via ALLEGRO_PATH, which has a al_get_path_filename for this purpose.
Thanks for your ideas.
Edgar, your approach seems to work using <string>.
Siegelord's apporach seems to do the job using allegro's built-in functions:
I recently added a FileSystem to my eagle library, which takes care of all these kind of things for you.