[Cuis-dev] macOS directory and file names containing colons
Bernhard Pieber
bernhard at pieber.com
Sun Mar 3 13:47:50 PST 2024
Hi,
In macOS Finder it is possible to create directories and file names which contain forward slashes. I created a directory named a/b with a file named b/c. Under the hood the slash is converted to a colon, e.g.
bernhard at MacBookPro16 Cuis-Smalltalk-Dev % find . -name b:c
./a:b/b:c
See also https://stackoverflow.com/questions/13298434/colon-appears-as-forward-slash-when-creating-file-name
In Cuis the names are shown with colons as well. The following expression answers true:
(DirectoryEntry vmDirectory directoryMatching: 'a:b') exists. „true“
However, the following expression answers false:
(DirectoryEntry vmDirectory / 'a:b') exists.
The reason for this is that on macOS the colon is not a separator – it was in Classic Mac OS, while Cuis assumes it still is, see String class>>#pathSeparators:
pathSeparators
^'\:/'
Seeing this implementation made me realize the same problem exists for directory and file names including a backslash. While I can create them in Finder, Cuis does not fully support them.
Creating such directories fails as well:
DirectoryEntry vmDirectory assureExistenceDirNamed: 'bin:go'.
DirectoryEntry vmDirectory assureExistenceDirNamed: 'bin\go‘.
Interestingly, using SqueakCompatibility the following works:
(FileDirectory on: '/Users/bernhard/Entwicklung/Cuis/Cuis-Smalltalk/Cuis-Smalltalk-Dev') createDirectory: 'bin:go'.
(FileDirectory on: '/Users/bernhard/Entwicklung/Cuis/Cuis-Smalltalk/Cuis-Smalltalk-Dev') createDirectory: 'bin\go‘.
The best fix would probably be to make the path separator platform dependent. (However, given that Smalltalk platformName returns 'Mac OS' even on macOS, I am not sure how best to distinguish between Classic Mac OS and macOS.)
Cheers,
Bernhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240303/a01ec391/attachment.htm>
More information about the Cuis-dev
mailing list