Thursday, 5 November 2015

Pharo's FileSystem





myCurrDirectory := FileSystem disk workingDirectory .

FileSystem 
     disk ( a class method)
 "Answer a filesystem that represents the 'on-disk' filesystem used by the host operating system."

root ( a class method)
^ self disk root

root
"Returns the root of the receiver filesystem, i.e. / on unix"
^ self referenceTo: Path root

So.
FileSystem disk
    creates a new FileSystem object

FileSystem disk workingDirectory
    creates a new FileSystem object and returns the current directory
FileSystem disk root
   creates a new FileSystem object, and  magically returns the root path [I currently do not understand this code]

I now understand this code!  Only 24 hours has past.
I'm betting:
FileSystem disk
    creates the new FileSystem instance, and returns
        aFileSystem, with a current disk
            Asking for its root location returns the fully qualified filepath to the root

changeDirectory: aPath
self workingDirectoryPath: (self resolve: aPath)  
   
resolve: aResolvable
^ aResolvable asResolvedBy: self

My brain hurts!


No comments:

Post a Comment