Pharo 2.0更改了一些基本的 API 位,我找不到执行以下操作的新方法:
FileDirectory default directoryNamed: aFolderString.
FileDirectory on: aFilename.
FileDirectory default assureExistenceOfPath: aString.
ReferenceStream on: stream.
新的等效代码是什么?是否有描述如何翻译或移植代码的更新指南?
以下陈述与您提出的问题相对应。
FileSystem workingDirectory / aFolderString
aFilename asFileReference
aString asFileReference ensureDirectory
aPathString asFileReference
解析aPathString
,所以如果你的名字中有斜杠,你最终会进入一个子目录。
/
另一方面,将单个目录或文件名作为参数,并且不解析进一步的子目录。根据您的平台,您可以轻松地引用名称foo/bar
中带有斜杠的文件FileSystem workingDirectory / 'foo/bar'
。
我收集了一些您可能会觉得有用的翻译:
+------------------------------------------------------+---------------------------------------------------------------------------+
| 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. |
+------------------------------------------------------+---------------------------------------------------------------------------+
ReferenceStream 不再受支持,在 Pharo 2.0 中已被删除。您应该使用编写良好、文档完善、测试良好且速度非常快的 Fuel。http://rmod.lille.inria.fr/web/pier/software/Fuel