David Cook
Well-known member
@olePigeon recently asked me about Tiny Transfer's file name limit. It got me to thinking about what the true file name limit is in classic Mac operating systems.
The original file system (MFS) claims to handle file names up to 255 characters in length -- but, hey, the Finder doesn't support more than 63 characters. And, the standard file box only has room for 63 characters. And, CurApName is only 31 characters. I feel like I should test this and see what I can get to crash.
The HFS file system and 128K ROMs are limited to 31 characters in length.
The System 7 FSSpec type uses a Str63 file name length. I assume this is to be compatible with MFS, and does not represent an expansion to 63 characters for HFS or foreign file systems like servers and CDs? ISO 9660 Level 2 specifies disk file names can't be longer than 31 characters, though.
-----
Research notes:
Inside Macintosh II:
Page 81: A file name consists of any sequence of 1 to 255 printing characters, excluding colons
). You can use uppercase and lowercase letters when naming files, but the File Manager ignores case when comparing names (it doesn't ignore diacritical marks). Warning: Your application should constrain file names to fewer than 64 characters, because the Finder will generate an error if given a longer name.
Inside Macintosh III:
Page 172: SFReply fName: STRING[63] {file name}
Page 160: CurApName Name of current application (length byte followed by up to 31 characters)
Inside Macintosh IV:
Page 90: File names and directory names consist of any sequence of 1 to 31 printing characters, excluding colons. You can use uppercase and lowercase letters when naming things, but the File Manager ignores case when comparing names (it doesn't ignore diacritical marks). 64K ROM note: The 64K ROM version of the File Manager allows file names of up to 255 characters. File names should be constrained to 31 characters, however, to maintain compatibility with the 128K ROM version of the File Manager.
Inside Macintosh Files:
Page 2-27: File and directory names consist of any sequence of 1 to 31 characters, excluding colons. You can use uppercase and lowercase letters in names, but the File Manager ignores case when comparing names.
Note: Although it is legal to use any character other than the colon in file, directory, and volume names, you should avoid using nonprinting characters in such names, even for temporary files that do not appear on the desktop or in the Standard File Package dialog boxes. A program written in C interprets a null character (ASCII code $00) as the end of a name; as a result, embedding the null character in a filename is likely to cause problems. In addition, file, directory, or volume names with null characters are not usable by AFP file servers (such as computers running Macintosh File Sharing or AppleShare software). In general, you should ensure that you use only printing characters in names of objects that you create in the file system.
[See Tech Note 102]
Page 2-242: FSSpec name Str63 filename or directory name
Page GL-3: filename A sequence of up to 31 printing characters, excluding colons, that identifies a file.
Tech Note 26:
Under the current font architecture, the font name is the resource name of the 'FOND' resource (let's forget about 'FONT'S altogether), so the font name can be any Pascal string. Unfortunately, this conflicts with the 31-character limitation of a file name when the System 7 Finder derives the file name ofa movable font file (Inside Macintosh Volume VI, page 9-34) from the font name. Some third-party fonts corne with font names long enough to cause trouble. You may also see this problem when trying to open a suitcase if the Finder can't generate distinct names for all of the fonts in the suitcase; the Finder may say the suitcase is "damaged" when it is not.
Tech Note 102:
This .file name looks outrageous.
There is a potential conflict between file names and driver names. If a file name is named something like.Bout, .Print or .Sony, then the file system will open the driver instead of the file. Drivers have priority on the 128K ROMs, and will always be opened before a file of the same name. This may mean that an application will get an error back when opening these types of files, or worse, it will get back a driver RefNum from the call. What the application thought was a file open call was actually a driver open call. If the program uses that access path as a file RefNum, it is possible to get all kinds of strange things to happen. For example, if .Sony is opened, the Sony driver's RefNum would be passed back, instead of a file RefNum. If the application does a Write call using that RefNum, it will actually be a driver call, using whatever parameters happen to be in the parameter block. Disks may be searching for new life after this type of operation. If a program creates files, it should not allow a file to be created whose name begins with '.'.
The original file system (MFS) claims to handle file names up to 255 characters in length -- but, hey, the Finder doesn't support more than 63 characters. And, the standard file box only has room for 63 characters. And, CurApName is only 31 characters. I feel like I should test this and see what I can get to crash.
The HFS file system and 128K ROMs are limited to 31 characters in length.
The System 7 FSSpec type uses a Str63 file name length. I assume this is to be compatible with MFS, and does not represent an expansion to 63 characters for HFS or foreign file systems like servers and CDs? ISO 9660 Level 2 specifies disk file names can't be longer than 31 characters, though.
-----
Research notes:
Inside Macintosh II:
Page 81: A file name consists of any sequence of 1 to 255 printing characters, excluding colons
Inside Macintosh III:
Page 172: SFReply fName: STRING[63] {file name}
Page 160: CurApName Name of current application (length byte followed by up to 31 characters)
Inside Macintosh IV:
Page 90: File names and directory names consist of any sequence of 1 to 31 printing characters, excluding colons. You can use uppercase and lowercase letters when naming things, but the File Manager ignores case when comparing names (it doesn't ignore diacritical marks). 64K ROM note: The 64K ROM version of the File Manager allows file names of up to 255 characters. File names should be constrained to 31 characters, however, to maintain compatibility with the 128K ROM version of the File Manager.
Inside Macintosh Files:
Page 2-27: File and directory names consist of any sequence of 1 to 31 characters, excluding colons. You can use uppercase and lowercase letters in names, but the File Manager ignores case when comparing names.
Note: Although it is legal to use any character other than the colon in file, directory, and volume names, you should avoid using nonprinting characters in such names, even for temporary files that do not appear on the desktop or in the Standard File Package dialog boxes. A program written in C interprets a null character (ASCII code $00) as the end of a name; as a result, embedding the null character in a filename is likely to cause problems. In addition, file, directory, or volume names with null characters are not usable by AFP file servers (such as computers running Macintosh File Sharing or AppleShare software). In general, you should ensure that you use only printing characters in names of objects that you create in the file system.
[See Tech Note 102]
Page 2-242: FSSpec name Str63 filename or directory name
Page GL-3: filename A sequence of up to 31 printing characters, excluding colons, that identifies a file.
Tech Note 26:
Under the current font architecture, the font name is the resource name of the 'FOND' resource (let's forget about 'FONT'S altogether), so the font name can be any Pascal string. Unfortunately, this conflicts with the 31-character limitation of a file name when the System 7 Finder derives the file name ofa movable font file (Inside Macintosh Volume VI, page 9-34) from the font name. Some third-party fonts corne with font names long enough to cause trouble. You may also see this problem when trying to open a suitcase if the Finder can't generate distinct names for all of the fonts in the suitcase; the Finder may say the suitcase is "damaged" when it is not.
Tech Note 102:
This .file name looks outrageous.
There is a potential conflict between file names and driver names. If a file name is named something like.Bout, .Print or .Sony, then the file system will open the driver instead of the file. Drivers have priority on the 128K ROMs, and will always be opened before a file of the same name. This may mean that an application will get an error back when opening these types of files, or worse, it will get back a driver RefNum from the call. What the application thought was a file open call was actually a driver open call. If the program uses that access path as a file RefNum, it is possible to get all kinds of strange things to happen. For example, if .Sony is opened, the Sony driver's RefNum would be passed back, instead of a file RefNum. If the application does a Write call using that RefNum, it will actually be a driver call, using whatever parameters happen to be in the parameter block. Disks may be searching for new life after this type of operation. If a program creates files, it should not allow a file to be created whose name begins with '.'.