[Pharo-project] FS: how to create a file?

Stéphane Ducasse stephane.ducasse at inria.fr
Fri Feb 4 16:59:19 CET 2011


Hi

I would like to write a test to see if children includes files 

| ref children alpha |
filesystem createDirectory: '/alpha'.
filesystem createDirectory: '/alpha/beta'.
filesystem createDirectory: '/alpha/gamma/'.

Now how do I create a file? There is createDirectory but not createFile.

I think that there is a lot of work before FS can get into the image.....

Stef




testChildrenWithFilesAndDirectories
	"Children of a reference are all the files and directories contained in this reference"
	"self debug: #testChildrenWithFilesAndDirectories"
	| ref children alpha |
	filesystem createDirectory: '/alpha'.
	filesystem createDirectory: '/alpha/beta'.
	filesystem createDirectory: '/alpha/gamma/'.
	filesystem working / '/alpha/gamma/'.
	alpha :=  filesystem referenceTo: '/alpha'.
	alpha / 'zork.text'.
	self halt.
	ref := filesystem referenceTo: '/alpha'.
	children := ref children.
	self assert: children size = 2.
	
	children do:
		[:child |
		self assert: child class = FSReference.
		self assert: (child isChildOf: ref).
		self assert: (#('beta' 'gamma') includes: child basename)]



More information about the Pharo-project mailing list