Pharo 2.0 changed some basic API bits, and I cannot found the new way of doing the following:
FileDirectory default directoryNamed: aFolderString.
FileDirectory on: aFilename.
FileDirectory default assureExistenceOfPath: aString.
ReferenceStream on: stream.
What would be the new equivalent code? Is there an update guide available describing how to translate or port code?
The following statements correspond do the ones you put in your question.
FileSystem workingDirectory / aFolderString
aFilename asFileReference
aString asFileReference ensureDirectory
aPathString asFileReference
resolves aPathString
, so if there are slashes in your name you will end up in a subdirectory.
/
on the other hand takes a single directory or file name as an argument, and does not resolve further subdirectories. Depending on your platform you can easily refer to a file named foo/bar
with a slash in the name with FileSystem workingDirectory / 'foo/bar'
.
I have collected some translations you may find useful:
+------------------------------------------------------+---------------------------------------------------------------------------+
| FileDirectory | FileSystem |
+------------------------------------------------------+---------------------------------------------------------------------------+
| FileDirectory assureExistence. | aString asFileReference ensureDirectory. |
| FileDirectory baseNameFor: aString. | aString asFileReference base. |
| FileDirectory containingDirectory. | Path parent asFileReference pathString. |
| FileDirectory default deleteFileNamed: aString. | aString asFileReference ensureDeleted. |
| FileDirectory default directoryExists: aString. | aString asFileReference exists. |
| FileDirectory default directoryNamed: aFolderString. | FileSystem disk / aFolderString. |
| FileDirectory directoryEntryFor: aString. | aString asFilereference. |
| (FileDirectory entryFor: aString) / 'filename'. | aString asFileReference / 'filename'. |
| FileDirectory extensionFor: aString. | aString asFileReference extension. |
| FileDirectory default fileExists: aString. | aString asFileReference exists. " or " DiskStore current isFile: aString. |
| FileDirectory default fullNameFor: aString. | aString asFileReference fullName. |
| FileDirectory default pathName. | FileSystem disk workingDirectory fullName. |
| FileDirectory on: aFilename. | aFilename asFileReference. |
| (FileDirectory on: aString) entries collect: #name. | aString asFileReference children collect: #basename. |
| (FileDirectory on: aString) entryAt: 'filename'. | aString asFileReference / 'filename'. |
| FileDirectory oldFileNamed: aString. | aString asFileReference readStream. |
| FileDirectory slash. | FileSystem disk separator. " or " DiskStore delimiter asString. |
+------------------------------------------------------+---------------------------------------------------------------------------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With