[Pharo-dev] [Pharo Trick: #0008] - If appropriate use the memory file system

Marcus Denker marcus.denker at inria.fr
Thu Dec 12 06:44:25 EST 2013


Related to that:

For Pharo4 I want to experiment to have the following:

1) one Memory FileSystem per RPackage (just an ivar there).
2) File Browser support to show all these so one can put files in the package filesystem
3) in Monticello, save all the files as part of the .zip (directory “resources”)
4) When loading with MC, load all files from the resources dir into the package filesystem

(at first the file support will be very simple, e.g. no support for diffs).

==> then store e.g. all the icons there instead of a MIME-Encode string.

	Marcus

On 12 Dec 2013, at 12:39, Torsten Bergmann <astares at gmx.de> wrote:

> -----------------------------------------------------------------------------------
> [Pharo Trick: #0008] - If appropriate use the memory file system 
> -----------------------------------------------------------------------------------
> Works in: Pharo 2.0, 3.0, ...
> -----------------------------------------------------------------------------------
> 
> It may be possible that your application has to export some
> data into an external file in a specific format. Pharo allows writing into
> a file using Streams as any other Smalltalk.
> 
> But sometimes you want to check the result right from the Pharo image 
> without having to look into the external file using external tools.
> 
> So the trick here is to use the memory file system instead 
> of the real disk file system during development since also no 
> cleanup on the hard disk is required afterwards:
> 
> |fs|
> fs := FileSystem memory.
> (fs / 'hello.txt') writeStreamDo: [:s| s nextPutAll: 'Exported data' ].
> (fs / 'hello.txt') readStream contents.
> 
> The memory filesystem is also nice if you need to work with files
> within a unit test. So when the test runs nothing remains left on the 
> hard disk.
> 
> If you need a real copy of the file on the hard disk you can also copy 
> from the memory file system to the disk file system using #copyTo:
> 
> |fs|
> fs := FileSystem memory.
> (fs / 'hello.txt') writeStreamDo: [:s| s nextPutAll: 'Memory first and then disk' ].
> (fs / 'hello.txt') copyTo: (FileSystem disk / 'exactCopy.txt')
> 
> 





More information about the Pharo-dev mailing list