user183928
user183928

Reputation: 783

Porting code to Pharo 2.0

Pharo 2.0 changed some basic API bits, and I cannot found the new way of doing the following:

  1. FileDirectory default directoryNamed: aFolderString.
  2. FileDirectory on: aFilename.
  3. FileDirectory default assureExistenceOfPath: aString.
  4. ReferenceStream on: stream.

What would be the new equivalent code? Is there an update guide available describing how to translate or port code?

Upvotes: 9

Views: 325

Answers (3)

Hernán
Hernán

Reputation: 1749

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.           |
+------------------------------------------------------+---------------------------------------------------------------------------+

Upvotes: 9

Damien Cassou
Damien Cassou

Reputation: 2595

ReferenceStream is not supported anymore and has been deleted in Pharo 2.0. You should use Fuel which is well written, well documented, well tested and very fast. http://rmod.lille.inria.fr/web/pier/software/Fuel

Upvotes: 5

camillobruni
camillobruni

Reputation: 2318

The following statements correspond do the ones you put in your question.

  1. FileSystem workingDirectory / aFolderString
  2. aFilename asFileReference
  3. aString asFileReference ensureDirectory
  4. ReferenceStream does no longer exist in 2.0.

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'.

Upvotes: 13

Related Questions