Path * '' vs. Path workingDirectory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Path * '' vs. Path workingDirectory

Alistair Grant
Hi All,

Is there any practical difference between (Path * '') and (Path
workingDirectory)?

Their internal representation is different:

- (Path * '') has one empty segment
- Path workingDirectory has no segments

But as far as I can tell they are otherwise the same:


| fs frEmpty frWD |

fs := FileSystem disk.
frEmpty := FileReference fileSystem: fs path: (Path * '').
frWD := FileReference fileSystem: fs path: Path workingDirectory.
String streamContents: [ :stream |
stream
        << 'frEmpty: ';
        << frEmpty printString; cr;
        << 'frWD: ';
        << frWD printString; cr;
        << '= : ';
        << (frEmpty absolutePath = frWD absolutePath) printString; cr.
]

'frEmpty: "File @ "
frWD: "File @ ."
= : true
'


Cheers,
Alistair

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Path * '' vs. Path workingDirectory

Guillermo Polito


On Sun, Aug 13, 2017 at 5:54 PM, Alistair Grant <[hidden email]> wrote:
Hi All,

Is there any practical difference between (Path * '') and (Path
workingDirectory)?

Being strict, Path workingDirectory does not make any sense. A path is relative or absolute. And it is relative to some other path.

I'd expect that Path workingDirectory gives you an absolute path to the current working directory,,,


Their internal representation is different:

- (Path * '') has one empty segment
- Path workingDirectory has no segments

But as far as I can tell they are otherwise the same:


| fs frEmpty frWD |

fs := FileSystem disk.
frEmpty := FileReference fileSystem: fs path: (Path * '').
frWD := FileReference fileSystem: fs path: Path workingDirectory.
String streamContents: [ :stream |
stream
        << 'frEmpty: ';
        << frEmpty printString; cr;
        << 'frWD: ';
        << frWD printString; cr;
        << '= : ';
        << (frEmpty absolutePath = frWD absolutePath) printString; cr.
]

'frEmpty: "File @ "
frWD: "File @ ."
= : true
'


Cheers,
Alistair




--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Path * '' vs. Path workingDirectory

Alistair Grant
Hi Guille,

Thanks for your reply.


On Mon, Aug 14, 2017 at 01:44:41PM +0200, Guillermo Polito wrote:

>
>
> On Sun, Aug 13, 2017 at 5:54 PM, Alistair Grant <[hidden email]> wrote:
>
>     Hi All,
>
>     Is there any practical difference between (Path * '') and (Path
>     workingDirectory)?
>
>
> Being strict, Path workingDirectory does not make any sense. A path is relative
> or absolute.

True, but Path is considered internal, so users shouldn't normally be
calling Path>>workingDirectory.

I'm asking because the patch I'm preparing to improve canonicalisation
affects the creation of the path in some instances ('.' asFileReference
used to have a path with an empty segment, now it has Path
workingDirectory).

Just for the record :-)

Path workingDirectory isRelative  " true"


> And it is relative to some other path.

Right, Pharo defines the image directory as the working directory (although
https://github.com/pharo-project/pharo/pull/92 will change that to the
more common shell interpretation of current working directory).


> I'd expect that Path workingDirectory gives you an absolute path to the current
> working directory,,,

But the path doesn't have a file system to resolve against.

Although even FileLocator workingDirectory gives a relative path.



Thanks again,
Alistair



>     Their internal representation is different:
>
>     - (Path * '') has one empty segment
>     - Path workingDirectory has no segments
>
>     But as far as I can tell they are otherwise the same:
>
>
>     | fs frEmpty frWD |
>
>     fs := FileSystem disk.
>     frEmpty := FileReference fileSystem: fs path: (Path * '').
>     frWD := FileReference fileSystem: fs path: Path workingDirectory.
>     String streamContents: [ :stream |
>     stream
>             << 'frEmpty: ';
>             << frEmpty printString; cr;
>             << 'frWD: ';
>             << frWD printString; cr;
>             << '= : ';
>             << (frEmpty absolutePath = frWD absolutePath) printString; cr.
>     ]
>
>     'frEmpty: "File @ "
>     frWD: "File @ ."
>     = : true
>     '
>
>
>     Cheers,
>     Alistair
>
>
>
>
>
> --
>                  Guille Polito
> [CNRS-filaire]
>
>                  Research Engineer
>
>                  French National Center for Scientific Research - http://
>                  www.cnrs.fr
>
>
>
>                  Web: http://guillep.github.io
>
>                  Phone: +33 06 52 70 66 13
>

Loading...