Search code examples
filesavesmalltalkpharo

When a path is not specified, where are files saved by default in Pharo?


I'm currently learning Pharo through the Pharo MOOC, and in the lecture "3.8 Stream Overview", we are presented the following example of a stream operation used to create files:

| stream |
stream := 'hello.txt' asFileReference writeStream.
stream nextPutAll: 'Hello Pharo!'.
stream close.

I executed this code snippet in playground, then I looked the folder where I installed Pharo, under ~/src/pharolauncher in Ubuntu 20.04, to check if the file was created, but it was nowhere in the folder or its subfolders.


Solution

  • You have a relative path and would like to convert it to absolute, right?

    OK. The key part of your code is

    'hello.txt' asFileReference
    

    If you inspect this object you will see its class is, not surprisingly, FileReference. Browse the class. Find some selector containing the word 'absolute' or 'Absolute'. The one that looks promising is #absolutePath. Give it a try.