The Timing of Time

Alan Lovejoy squeak-dev.sourcery at forum-mail.net
Mon Apr 17 16:24:18 UTC 2006


Stéphane: "Does it mean that you have an abstraction over the ugly
FileDirectory and friends."

Yes, Passport provides an abstraction layer over FileDirectory, in three
different senses:

1. Like a VisualWorks Filename, a ResourcePath has behavior appropriate for
handling file names as such, as opposed to String mangling.

2. ResourcePaths can also be used as URL objects--using the same API as when
they represent "Filenames."  Whether the String representation of a
ResourcePath looks like a host-platform filename string, or like a File URL
(or like an HTTP URL) is a function of which Strategy object is associated
with the instance.

3. ResourcePaths provide cross-platform portability, in two different
senses.  Firstly, a single instance can represent the same relative path on
any of Windows, UNIX, the classic MacOS or RiscOS.  Absolute paths are
necessarily host-platform specific, although the platform-specific part of
the path can be represented as mutable data in the ResourcePathContext
associated with each ResourcePath (the same ResourcePathContext can be bound
to any number of ResourcePaths.)  Secondly, Passport provides portability of
the code that uses ResourcePaths to all Smalltalk environments to which
Passport has been ported, which for now means VisualWorks and
Squeak--although the Dolphin port will be available soon.

Stéphane: "So we could have this kind of behavior
	File default recursivelyDo: [:each | where each would be a
resourcepath] ?"

| handleFile handleDirectory |
handleFile := [:file | file extension = 'bak' ifTrue: [file delete]].
handleDirectory :=
	[:directory |
		directory contentsDo:
			[:resourcePath |
				resourcePath isDirectory
					ifTrue: [handleDirectory value:
resourcePath]
					ifFalse: [handleFile value:
resourcePath]]]
handleDirectory value: ResourcePath defaultDirectory

-----Original Message-----
From: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of stéphane
ducasse
Sent: Sunday, April 16, 2006 11:48 PM
To: The general-purpose Squeak developers list
Subject: Re: The Timing of Time

HI alan

this sounds really interesting.
Does it mean that you have an abstraction over the ugly FileDirectory and
friends.

> Passport provides the class ResourcePath, which is conceptually a
> union of a VisualWorks Filename with a URL object. ResourcePaths
> support HTTP URLs, File URLs and native filenames (in the latter case,
> using native filename syntax--Windows, Unix or Classic MacOS.) In
> VisualWorks, they also support FtpURLs and HttpsURLs (and it wouldn't
> be all that hard to do the same in
> Squeak.)  Note that ResourcePaths can do all that without any
> subclasses--they use the Strategy pattern instead.

So we could have this kind of behavior
	File default recursivelyDo: [:each | where each would be a
resourcepath] ?

>
> The Squeak implementation of Passport includes the classes
> HttpRequest and
> HttpResponse, which implement HTTP 1.1 with both client-side and
> server side
> functionality. You might find that to be of some interest, in view
> of the
> mess that is HTTPSocket.






More information about the Squeak-dev mailing list