Alternative directory/file classes?
Keith Hodges
keith_hodges at yahoo.co.uk
Sun Mar 11 15:46:03 UTC 2007
Dear Andreas,
with this in mind I have been working on Rio, inspired by a generally
useful io library for ruby. After not much work I am quite pleased with
the results for far.
simple stuff, building paths.
myFile := Rio default / 'hello' + '.txt'. "or even Rio / 'hello' as an
abbreviation"
testing & stat stuff:
self assert: (myFile exists).
self assert: (myFile isFile).
self assert: (myFile parent isDirectory).
mt := myFile modificationTime.
ct := myFile creationTime.
size := myFile size.
accessing path bits.
self assert: (myFile basename = 'hello')
self assert: (myFile ext = 'txt')
self assert: (myFile filename = 'hello.txt')
changing rio filename:
myFile ext: 'text'.
myFile basename: 'goodbye'.
myFile filename: 'goodbye.dat'.
renaming files in filesystem:
myFile rename ext: 'text'.
myFile rename basename: 'goodbye'.
myFile rename filename: 'goodbye.dat'.
myFile renameTo: 'world.txt'.
reading writing etc.
myFile write in: [ :str | ].
myFile < 'contents'.
allContents := myDirectoryRio files collect: [ :f | f read contents ].
more iterating:
Rio default all select: [ :stat | (stat filename endsWith: '.st') &
fStat modificationTime > '1-1-07' asDate) ]
I did a brief comparison with FileMan
http://wiki.squeak.org/squeak/5929
rio is available from http://www.squeaksource.com/Rio
Rio is different to Fileman in that it does not use FileDirectory at
all, instead it re-implements all of the same functionality and much of
FileMan's. Doing so has enabled great economies. Fileman + FileDirectory
is about 110k of source. RioKernel is 8k with Rio-Core being another 20k.
Rio is experimental, most of it works, there are extensive ramblings of
ideas in the class comments. Encoding is not yet supported, because I
don't fully understand how it is used yet. The plan is to break Rio down
into modules, specifically into a bare minimum "RioKernel" for those
interested in producing KernelImages. At present I am defining
RioKernelTests collecting the use cases for defining this Kernel. Once
RioKernel is defined I hope to be able to make FileDirectory unloadable. :-)
thats as far as it goes so far... more to come
Keith
>
> Recently I got (once again ;-) horribly disgusted by the mess in the
> current file/directory classes in Squeak and started looking for
> alternatives. Besides Flow (which I knew about but which is a bit too
> far-reaching for what I'm after) I was particularly impressed by
> looking at FileMan which seemed a nice and simple interface to do all
> the practical things that you need when dealing with
> files/directories. A couple of questions related to it:
> 1) Is anyone using FileMan in production environments? How does it
> hold up in practice?
> 2) I presume FileMan still requires FileDirectory and friends in all
> their splendid uglyness. Has anyone looked at making FileMan the only
> interface to access directories?
> 3) Are there any other directory/file interfaces I should be looking
> at in my quest for a bit more cleanliness in these areas?
>
> Cheers,
> - Andreas
>
>
___________________________________________________________
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html
More information about the Squeak-dev
mailing list
|