将代码移植到Pharo 2.0

时间:2013-04-02 06:26:51

标签: stream smalltalk pharo

Pharo 2.0更改了一些基本的API位,我无法找到执行以下操作的新方法:

  1. FileDirectory default directoryNamed: aFolderString.
  2. FileDirectory on: aFilename.
  3. FileDirectory default assureExistenceOfPath: aString.
  4. ReferenceStream on: stream.
  5. 新的等效代码是什么? 是否有可用于描述如何翻译或移植代码的更新指南?

3 个答案:

答案 0 :(得分:13)

以下陈述与你提出的问题相对应。

  1. FileSystem workingDirectory / aFolderString
  2. aFilename asFileReference
  3. aString asFileReference ensureDirectory
  4. 2.0中不再存在ReferenceStream。
  5. aPathString asFileReference会解析aPathString,所以如果你的名字中有斜杠,你将会进入一个子目录。

    另一方面,

    /将单个目录或文件名作为参数,并且不解析其他子目录。根据您的平台,您可以使用foo/bar轻松引用名为FileSystem workingDirectory / 'foo/bar'的文件,名称为斜杠。

答案 1 :(得分:9)

我收集了一些您可能会觉得有用的翻译:

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

答案 2 :(得分:5)

不再支持ReferenceStream,并已在Pharo 2.0中删除。您应该使用写得很好,记录良好,经过良好测试且速度非常快的燃料。 http://rmod.lille.inria.fr/web/pier/software/Fuel