Pharo 2.0更改了一些基本的API位,我无法找到执行以下操作的新方法:
FileDirectory default directoryNamed: aFolderString.
FileDirectory on: aFilename.
FileDirectory default assureExistenceOfPath: aString.
ReferenceStream on: stream.
新的等效代码是什么? 是否有可用于描述如何翻译或移植代码的更新指南?
答案 0 :(得分:13)
以下陈述与你提出的问题相对应。
FileSystem workingDirectory / aFolderString
aFilename asFileReference
aString asFileReference ensureDirectory
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