GP32 Filename


pea

developer
Joined
Oct 3, 2004
Messages
1,089
Age
46
Location
New Zealand
Website
www.projectitis.com
unsigned char *filename;
or
char *filename?

Personally I have a few rules:
1) I always use unsigned char (as ascii/ansi goes 0 up)
2) alsways end filepath in a slash after folder name. No slash indicates file

Am I doing it right? What are the actual conventions if any?
 
Signed or unsigned doesn't matter, because they only differ if bit 7 is set, ie. if the signed number is negative / the unsigned number is >127. There are other rules though that govern characters that are acceptable for filenames, and the acceptable ones (in DOS anyway) are all less than 128.

Whether or not "char" should be signed or unsigned is a religious war that rages amongst the pedants of the world. Use whichever you prefer, and causes your compiler to complain the least :)

There's no real standard for whether a trailing slash is necessary on a pathname. Usually it's obvious from the context:
Code:
fopen ("gpmm/","rt");
is obviously wrong - but there are lots of exceptions and inconsistencies (especially within "standards" like POSIX). Careful programmers will strip/add trailing slashes as necessary. I'm sure everyone's written a function to check whether a pathname has a slash, and add one if not. It's kind of a rite of passage.

So all up, IMHO, there's no real answers and everyone should just please themselves :D
 
Back
Top