GP32 Filenames And Path Problems


ConsoleTom

Member
Joined
Dec 4, 2003
Messages
106
Age
48
Location
Germany
Website
Visit site
Hi !

I am writing a file requester for my program (i use devkitadv) and have a problem:

The commands for using the filesystem want lower-case filenames but i have all upper-case. How do i convert upper to lower ?

Greetings

Tobias
 
Hi !

I am writing a file requester for my program (i use devkitadv) and have a problem:

The commands for using the filesystem want lower-case filenames but i have all upper-case. How do i convert upper to lower ?

Greetings

Tobias
a simple way (if you are sure you have only upper-case letters, no digits)

each char has an integer value ('a'=60, 'b'=61.... 'A'=100,'B'=101 ...) (value are just examples)
so to convert a 'A' to 'a' just do 'A'-('A'-'a') ( ('A'-'a') is a constant you can use for every letters)
so to convert a 'B' to 'b'... 'B'-('A'-'a')...
to convert a string just apply this trick on every char
 
Last edited by a moderator:
gpmem.h has the following two functions (never tried using them myself though)

void gm_lowercase(char * ptr, int count);
void gm_uppercase(char * ptr, int count);
 
Hi !

Thanks.

But i'm not sure that there are only chars and no digits, since the filesystem allows it.

I have an idea: Could i test if there are letters ? Like this ?

if (str >= 'A' && str <= 'Z')
... do lowercase ...

Greetings

Tobias
 
gm_lowercase and gm_uppercase will convert only alphabetical character, you have nothing to worry about digits or other special charcaters
 
Back
Top