[A5] Questions regarding the "File System Routines"
TeaRDoWN

1. How to get file names without their paths?
The al_get_fs_entry_name() return the full path+name of a file or directory, not only the name.
Is it possible to get only the name or do I simply have to trim the string myself? What I get is: "mods\AAL2D\gfx\ingame\blood.png" and what I want: "blood.png".

2. Can I filter the result on specific file extensions?
In A4 it was possible to filter the result by entering a specific file extension into al_findfirst().
I do not see anything like that in A5 when looking in the manual and examples. Do I have to filter this myself by comparing last part of string?

Arthur Kalliokoski
TeaRDoWN said:

1. How to get file names without their paths?

basename()

Quote:

2. Can I filter the result on specific file extensions?

If you click on your own link al_findfirst(), it gives an example of searching for pcx files.

torhu

There is an al_get_path_basename() function, if you want something more portable than basename. You would then have to create (and destroy) a temporary ALLEGRO_PATH.

Todd Cope
  1. You can use the path routines. al_get_path_filename() will get the filename.

  2. A5 does not provide a way to filter by extension.

Thomas Fjellstrom

And if you already have an ALLEGRO_PATH for the file, you can use al_get_path_extension() to get the extension :)

TeaRDoWN

Arthur: I know that you filter with al_findfirst() but it is an A4 function and does not exist in A5 which I've moved over to.

Ok, thank guys for the answers. I'll use the al_get_path... functions to get the name and to filter on the extension.

Thread #608812. Printed from Allegro.cc