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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Torsten Bergmann
-----------------------------------------------------------------------------------
[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')


Reply | Threaded
Open this post in threaded view
|

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

Marcus Denker-4
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 <[hidden email]> 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')
>
>


Reply | Threaded
Open this post in threaded view
|

[Pharo Trick: #0009] 'Enable halt/inspect once' button

Ben Coman
When I have a 'self haltOnce' breakpoint that I am activating often,
going "World > System > Enable halt/inspect once" each time is
annoying.  So using the Duplicate Halo on the menu item, I drag it onto
the background so that it acts like a button.

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] [Pharo Trick: #0009] 'Enable halt/inspect once' button

Ben Coman
Max Leske wrote:
#setHaltOnce is implemented on Object. Evaluate this in a workspace:

self setHaltOnce.

-> same effect

Cheers,
Max

  
Yes :)
But each time I must::
* Search for the correct workspace among several open workspaces, as well as lots of other windows for Finder, Browser, Debugger, Inspectors
* Use the mouse to highlight that text (three actions - click, drag, release)
* Use the keyboard for cmd-d, or two more actions with the mouse to select from menu

Versus:
* one click on a button that is 'always on top'

I guess Trick #0004 is now also an option.

cheers -ben

On 12.12.2013, at 13:06, [hidden email] wrote:

  
When I have a 'self haltOnce' breakpoint that I am activating often, going "World > System > Enable halt/inspect once" each time is annoying.  So using the Duplicate Halo on the menu item, I drag it onto the background so that it acts like a button.

cheers -ben