The formatFilename: method can be used to shorten its filename argument to fit the volumes' maximumFilenameLength restrictions by dropping vowels and truncating, if necessary. This method assumes that a maximumFilenameLength of 12 indicates that file names should consist of eight characters, optionally followed by a period and a three character extension. The formatFilename: method does not detect or suppress characters that are not valid.
File names should be composed of the POSIX.1 portable file name characters, which are listed in "Portable file names".
The following example forces a file name to conform to the file name length and case of the volume specified by path. For further information on the systemErrorDialog: method, see Suppressing system error dialogs.
"Modify the file name for the file about to be saved to path, ignoring all errors, including drive not ready." | filename path state volumeInfo newFilename | filename := 'aVeryLongFilenameWhichWontFitOnSomeSystems.Text'. path := 'a:\workdir'. "Obtain volume information" (volumeInfo := CfsVolumeInfo new) volumeInfo: path. "Force the filename to fit" newFilename := volumeInfo formatFilename: filename. "Answer the full path" ^path last = CfsDirectoryDescriptor pathSeparator ifTrue: [ path, newFilename] ifFalse: [ path, CfsDirectoryDescriptor pathSeparatorString, newFilename]