[squeak-dev] Accessing external resources in a cross-platform way

David T. Lewis lewis at mail.msen.com
Fri Jan 28 13:58:49 UTC 2011


On Fri, Jan 28, 2011 at 01:51:22PM +0100, Hern??n Morales Durand wrote:
> Let's say you want to resolve paths in a cross platform way
> 
> Binaries @ 'MyExec'
> Libraries @ 'MyLib'
> SystemLibraries @ 'SystemLib'
> etc.
> 
> then Binaries is
> 
> In Windows: #( 'C:\Program Files\' 'C:\Archivos de Programa\' ...) "
> and all standard locations including translations "
> In UNIX: #('/usr/bin/' '/usr/local/bin' ....) " and all standard locations "
> etc
> 
> Now you may say it is necessary to scan all directories to find
> MyExec, yes but you may then save that location
> 
> myBinaryLocation := Binaries @ 'MyExec'.
> 
> so you scan for it just once.
> 
> What do you think? it is already implemented anywhere?
> If not what package do you think is more suitable or prepared for
> implementing it?

Hern??n,

This is of course very platform dependent, and it is more complex
than you might expect due to differences in file systems, operating
systems, volume names (windows), environment variables and search
path conventions.

Both Windows and Unix use various seach paths accessible through
environment variables, and the conventions for this tend to change
over time with different OS versions. So it would probably be best
to rely directly on those environment variables for identifying
search paths.

Aside from the conventions for default locations and search paths,
some of what you are looking for may also be implemented for Windows
and Unix in SqS/CommandShell in class ShellSyntax:

   My instances implement parsing of strings in a manner similar to
   a simple Unix command shell. I provide path name expansion in the
   context of an external file system, and support the syntax required
   for IO redirection. All file name globbing and PATH searching are
   implemented in Smalltalk rather than in C library functions or an
   external command shell.
   
   Most of my syntax is applicable for any operating system. Where
   needed, platform specific methods are in my "platform dependent"
   category. Currently, Unix and Windows are supported, and other
   platforms have not been tested. The primary difference between
   Unix and Windows support is that device names (such as 'C:') are
   used in Windows path strings. Separate current working directory
   strings are maintained for all Windows device names. For Unix,
   a single current working directory path is used. On Windows,
   this permits the CommandShell 'cd' command to support changing
   directories to another device without losing track of the current
   working directory for the previous device.
   
   Command pipeline syntax is not supported here. See CommandShell
   for the implementation of command pipelines.

Dave




More information about the Squeak-dev mailing list