Hello.
The filename does not need to exist. It must be simply valid. Thank you for your answers. Best regards, Tom Grünewald ________ Carl Zeiss Industrielle Messtechnik GmbH Softwareentwicklung/Software Development T o m G r ü n e w a l d 73446 Oberkochen, Germany tel: +49.7364.20-8541 fax: +49.7364.20-4800 email: [hidden email] http://www.zeiss.de/imt Carl Zeiss Industrielle Messtechnik GmbH, Carl-Zeiss-Straße 22, 73447 Oberkochen Aufsichtsratsvorsitzender: Dr. Dieter Kurz Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Hanspeter Mürle Sitz der Gesellschaft: 73446 Oberkochen, Deutschland Handelsregister: Amtsgericht Ulm, HRB 501561 USt-IdNr.: DE 811 515 346 ---------------------------------------- This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Tom,
I am not sure all of those conditions can be tested, and certainly not simply.
One of the easiest checks is:
valid := ([inputString asFilename] on: Error do: [:ex | ex return: nil]) ifNil: [false] ifNotNil: [:fn | fn asString asUppercase = inputString asString asUppercase].
This should handle illegal characters, improper space characters (if those are checked, because they’re legal on Unix), and double separators. Double separators are not usually an issue except in the old MacOS (pre-OSX), since the double colon (“::”) meant the equivalent of Unix’s “..” for parent directory. They’re typically ignored, but the string comparison will detect the removal of duplicates. If anything else got removed, say because of length restrictions, the two strings won’t compare either. I don’t have the code up so I don’t know if there is a maximum length check in the various platform specializations.
Checking for legal volume names requires knowing that you’re on Windows (or VMS) and making explicit system library calls to validate the volume information. There have been other postings on either the VW-DEV or VWNC lists on how to do that. Without going through that hassle, you could extend the above to do the following instead:
valid := ([inputString asFilename] on: Error do: [:ex | ex return: nil]) ifNil: [false] ifNotNil: [:fn | (fn asString asUppercase = inputString asString asUppercase) and: [[fn definitelyExists. true] on: Error do: [:ex | ex return: false]]].
I think this will work even if the file name references non-existent files or directories. Because on Unix this would basically be a stat() call, any error in reaching the target would result in a failure. Only if the stat actually succeeded would the associated primitive action return true. But I’m not looking at the VM code, either, so I don’t know if some conditions would result in a false (e.g., “not found” for missing directories) and others would result in an exception (e.g., illegal file name string). If they’re split, then the above should detect them.
Cheers!
From:
[hidden email] [mailto:[hidden email]] On Behalf Of Gruenewald, Tom
Hello.
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |