quote:Original post by Xces
So you prefer the implementation of the char for char lowercasing, or do you have another idea for that?
I''d prefer it over relying on a potentially non-existant strlwr function. You can always just write the loop version as your own strlwr function (you might not want to name it that, that''s up to you). I''m should post my ''GetFileExtension'' function as long as I''m replying (it''s in C, but it''s easy to C++-ify it, just change found_period to a bool, 0 to false, and 1 to true):
const char *GetExtension(const char *filepath) { int found_period = 0; for( ; *filepath != ''\0''; ++filepath) { if(*filepath == ''.'') { found_period = 1; break; } } if(found_period == 0) return NULL; while(*filepath != ''\0'') ++filepath; while(*filepath != ''.'') --filepath; return &filepath[1];}
Since it basically just returns an offset to the data after the last period (or NULL if there is no period) it doesn''t have any limitations with extension length. It doesn''t copy the extension into a new string because of this.