From: Jacek S. <arn...@gm...> - 2007-11-15 18:22:24
|
Well, two separate functions would indeed be reasonable...keep in mind that each OS has its own rules so I'd expect mac to be slightly different as well...windows names are extra ugly (lots of reserved names etc) and the current code doesn't take all cases into consideration (see http://msdn2.microsoft.com/en-us/library/aa365247.aspx, for example CON, NUL and friends)... Maybe the easiest way to handle paths would be to split them into their respective components and then validatefilename for each part, considering also dots and the like...oh, and / is a valid path separator on windows most of the time... oh, and itinerants, find_first_of might interest you (instead of repeating those loops =) /J poy wrote: > yep. i can imagine 3 functions instead of 1 currently: > - cleanBadChars(string tmp) would clean any occurence of badChars[] > found in tmp. > - validatePath would be the current validateFileName, making use of > cleanBadChars in its first part. > - a new validateFileName would handle filename sanitisation, making use > of cleanBadChars and then cleaning the remaining '\\' if win32 or '/' > otherwise. > |