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

Lukas Renggli renggli at gmail.com
Fri Feb 4 17:10:06 CET 2011


Stef,

There is not much sense in creating a file without also putting
something inside. There are various methods that give you a write
straeam onto a new file.

Also note that FSFilesystem>>#createDirectory: is a private method,
like about all other methods in there too. You are not supposed to
call it directly.

Lukas

On Friday, 4 February 2011, Stéphane Ducasse <stephane.ducasse at inria.fr> wrote:
> 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)]
>

-- 
Lukas Renggli
www.lukas-renggli.ch




More information about the Pharo-project mailing list