Re: Directory separators on Windows

From: Date: Mon, 03 Apr 2017 16:48:51 +0000
Subject: Re: Directory separators on Windows
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-98726@lists.php.net to get a copy of this message
On 4/2/2017 8:28 PM, Rowan Collins wrote: > On 02/04/2017 09:09, Fleshgrinder wrote: >> Your strategy works in these examples, but the example I gave was >> different. Imagine that we have /a/b/../c which we would >> normalize to >> /a/c. However, the b >> component is actually a symbolic link to x/y. >> Hence, the real version of the path is /a/x/c and not >> /a/c as we >> would have normalized it to. > > Both strategies are equally valid, as long as you know which is in use. > There are many common tools outside PHP which use both approaches, and > situations where you might actually want the string-based approach, even > if filesystem access is available. > > See for instance this discussion of pwd: > http://unix.stackexchange.com/q/331208/70530 In summary, POSIX > specifies > "-L" (logical) which uses $PWD as set by the shell as you navigate, and > "-P" (physical) which resolves backwards through the ".." links in the > file system. > > The same is true for other operations - for instance, the below demo in > bash shows one interpretation in "ls" and the other in "cd". > > > /tmp/demo$ ls -lR > .: > drwxr-xr-x 2 vagrant vagrant 4096 Apr 2 18:21 foo > drwxr-xr-x 3 vagrant vagrant 4096 Apr 2 18:05 other > > ./foo: > lrwxrwxrwx 1 vagrant vagrant 21 Apr 2 18:21 bar -> /tmp/demo/other/thing > > ./other: > drwxr-xr-x 2 vagrant vagrant 4096 Apr 2 18:06 thing > > /tmp/demo$ ls foo/bar/.. > thing > > /tmp/demo$ cd foo/bar/.. > /tmp/demo/foo$ ls > bar > > Regards, > I get your point, and I have to agree here. normalize_path/Path::normalize would be the counterpart to realpath/Path::canonicalize. 👍 -- Richard "Fleshgrinder" Fussenegger

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#98726) next »