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

2013-12-12 Thread Marcus Denker
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 asta...@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')
 
 




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

2013-12-12 Thread Torsten Bergmann
Hi Marcus,

regarding 2) In Pharo 3.0 one can already open a file browser on the 
memory file system:

|fs|
fs := FileSystem memory.
(fs / 'hello.txt') writeStreamDo: [:s| s nextPutAll: 'Exported data' ].
FileList openOn: fs root

but it looks like it needs some love. One can create new files but most
functionality will not work. Should we create an issue?

Thx
T.

 Gesendet: Donnerstag, 12. Dezember 2013 um 12:44 Uhr
 Von: Marcus Denker marcus.den...@inria.fr
 An: Pharo Development List pharo-dev@lists.pharo.org
 Cc: Any question about pharo is welcome pharo-us...@lists.pharo.org
 Betreff: Re: [Pharo-dev] [Pharo Trick: #0008] - If appropriate use the memory 
 file system

 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 asta...@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')