[plt-scheme] Explode-path and normalized file paths

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sun Sep 24 08:05:48 EDT 2006

Matthew Flatt skrev:
> At Sun, 24 Sep 2006 00:45:41 +0200, Jens Axel Søgaard wrote:

>> Is it correct to assume that this means, the path
>>
>>      c:/tmp/planet/source/cce\website.plt\current\private\require.ss
>>
>> is normalized on Windows, but not on Linux?


> Yes. It's not an absolute path on Windows.

You mean on Linux, right?

Linux:

   > (explode-path (string->path "c:/bar/foo.txt"))
   explode-path: expects argument of type <path in normal form>; given
   #<path:c:/bar/foo.txt>

Windows:

     > (explode-path (string->path "c:/bar/foo.txt"))
    (#<path:c:/> #<path:bar> #<path:foo.txt>)

 > The `explode-path' function actually needs an absolute path that has
 > no "." or ".." in it. I'll change the error message and the docs.

Wait! Boy I am slow. It wasn't until now I realized that a path is
normalized relative to a *particular* file system. So for normalization,
it isn't a Windows vs Linux problem at all. In principle I'd have the
same problem [with normalize-path, not with explode-path], if I moved 
the data to another Windows box with a different file structure.

In the case of explode-path, there is no normalization problems, but
there is still the twist that "absolute path" means different things
on Windows and Linux.

> I think you probably need `full-path' to be an absolute path for this
> application. 

In Windows they were ;-)

In my program the original files are still at the Windows machine,
the only thing I need on the Linux machine is their relative paths.
I used absolute paths, because I wanted to use explode-path.
Maybe Herman's explode-relative-path could be added to (lib "file.ss")?

    <http://ja.soegaard.net/planet/html/dherman/io.plt/current/>

> Unless you want to support "." and "..", then `explode-path' is still 
 > probably the thing to use. But you can always write a loop with
 > `split-path'.

A quick hack must be to convert the path to a string, remove the c:
and then convert back to a path, before calling explode-path.

-- 
Jens Axel Søgaard



Posted on the users mailing list.