[squeak-dev] Re: [ANN] Filesystem 1.0
Colin Putney
cputney at wiresong.ca
Sat Nov 21 06:46:12 UTC 2009
On 20-Nov-09, at 9:21 PM, Andreas Raab wrote:
> Colin Putney wrote:
>> Feedback appreciated!
>
> I guess the big question here is: To what extent is this a feasible
> replacement of FileDirectory and/or [Standard|CrLf|
> MultiByte]FileStream?
Well, my intention is to create a complete replacement. I've found
FileDirectory, in particular to be a major stumbling block. What I
released today is, I think, a good replacement for FileDirectory. It's
not yet a complete replacement for FileStream. The stream
implementations are pretty basic, and don't do much beyond moving
bytes in and out of the image. That's all I needed for my immediate
needs.
I expect that to improve, but in the meantime, it's possible to use
StandardFileStream with FSDiskFilesystem subclasses, and there are
compatibility streams for FSMemoryFilesystem and FSZipFilesystem. So
it's possible to start using Filesystem to replace FileDirectory, and
keep using FileStream until the FS stream implementations mature. To
put it another way, compatibility with FileStream is a non-goal for
the design of the native FS streams, but having a smooth migration
path *is* a goal. I've got legacy code that I need to convert!
> Besides that, a couple of smaller comments and questions:
>
> * How does one convert 'D:\Squeak\3.10' to the equivalent to a
> FileDirectory? I.e., what's the equivalent to
>
> fd := FileDirectory on: 'D:\Squeak\3.10'.
ref := FSWindowsFilesystem stringToReference: 'D:\Squeak\3.10'.
> and then (to make the example more concrete):
>
> (fd fileNamesMatching:'*.txt') do:[:oldName|
> newName := (oldName allButLast: 4),'.bak'.
> [oldFile := fd readOnlyFileNamed: oldName.
> newFile := fd forceNewFileNamed: newName.
> fd copyFile: oldFile toFile: newFile] ensure:[
> oldFile close.
> newFile close.
> ].
> ].
(ref children select: [:child | child isFile and : [child basename
endsWith: '.txt']]) do:
[:oldRef |
newRef := oldRef withExtension: 'bak'.
oldRef copyTo: newRef].
Hmm, a few convenience methods would clean up that top line a bit.
> * What about Windows \\shares\? Many (most?) network file systems
> aren't mapped to drives any longer so the access to \\shares\ is
> fairly important.
Not yet implemented. Not being a Windows user, I used VMware to test
the Windows stuff, but of course I'm not on a network. I don't see any
reason it would be difficult.
> * Nitpick: On Windows, FSPlatformTest>>testHome will generally fail.
> That's because the home location is different between Windows
> versions (it's C:\Documents and Settings\ on XP, C:\Users on Vista
> and Windows 7) but also because that path is localized (i.e.,
> "Dokumente und Einstellungen" on a German XP variant). Your best
> guess (short of a dedicated primitive) is currenty
>
> (FileDirectory on: SecurityManager default untrustedUserDirectory)
> containingDirectory containingDirectory
>
> since the untrustedUserDirectory nowadays defaults to <home>\My
> Documents\My Squeak (unless overridden).
Nice catch, thank you. I actually have an implementation of
FSWindowsResolver>>home that does the equivalent of the above, but it
seems to have gone missing. I'll fix in the next release.
Colin
More information about the Squeak-dev
mailing list
|