Re: [PHP-DEV] Directory separators on Windows

2017-04-03 Thread Fleshgrinder
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

Re: [PHP-DEV] Directory separators on Windows

2017-04-02 Thread Rowan Collins
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

Re: [PHP-DEV] Directory separators on Windows

2017-04-02 Thread Fleshgrinder
On 4/1/2017 6:15 PM, Anatol Belski wrote: > Basically, it is the same as your points 8., 9. and 10. - it deals > with the given path itself, so no symlinks, etc. In the snippet > /a/b/../c it's parsed like follows > > - parse up to /a/b/../ - scroll back to /a - append the remain so it > becomes

RE: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Anatol Belski
> -Original Message- > From: Fleshgrinder [mailto:p...@fleshgrinder.com] > Sent: Saturday, April 1, 2017 2:43 PM > To: Anatol Belski <weltl...@outlook.de>; Rasmus Schultz > <ras...@mindplay.dk> > Cc: PHP internals <internals@lists.php.net> > Subj

Re: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Rasmus Schultz
10 thumbs up ;-) But this really demonstrates how badly we need this function - I bet any number of those points may or may not be covered by any number of implementations in the wild. It would be so nice to have this done "right", once and for all. On Sat, Apr 1, 2017 at 2:42 PM, Fleshgrinder

Re: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Fleshgrinder
On 4/1/2017 2:01 PM, Anatol Belski wrote: > 1. optionally - yes, otherwise it should do platform default > 2. no, this kind of operation is a pure parsing, no I/O related checks needed > 3. irrelevant, but can be defined > > Other points yet I'd care about > - result should be correct for target

RE: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Anatol Belski
;internals@lists.php.net> > Subject: Re: [PHP-DEV] Directory separators on Windows > > > Also ucfirst is useless (or any case operations) > > It's not useless, if you want a normalized path on Windows, it has to include > a > drive-letter, and Windows FS isn't case-sensiti

Re: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Fleshgrinder
On 4/1/2017 1:03 PM, Anatol Belski wrote: > " A Uniform Resource Identifier (URI) is a compact sequence of > characters that identifies an abstract or physical resource" they > say. Fits perfectly with PHP streams. > The problem I was referring to is not semantically. The problem is that the

RE: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Anatol Belski
> -Original Message- > From: Fleshgrinder [mailto:p...@fleshgrinder.com] > Sent: Saturday, April 1, 2017 12:00 AM > To: Anatol Belski <a...@php.net>; internals@lists.php.net; Rasmus Schultz > <ras...@mindplay.dk> > Subject: Re: [PHP-DEV] Directory separator

Re: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Fleshgrinder
On 4/1/2017 11:13 AM, Rasmus Schultz wrote: > So to summarize, a normalize_path() function should: > > 1. Fully normalize to an absolute path with no platform-specific separators > 2. Have corrected case (for files/dirs that do exist.) > 3. Have normalized (upper-case) drive-letter on Windows >

Re: [PHP-DEV] Directory separators on Windows

2017-04-01 Thread Rasmus Schultz
> Also ucfirst is useless (or any case operations) It's not useless, if you want a normalized path on Windows, it has to include a drive-letter, and Windows FS isn't case-sensitive. > Right now realpath will fail if the path does not exist I know, that's one reason I don't use it. It kind of

Re: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Fleshgrinder
On 3/31/2017 9:29 PM, Anatol Belski wrote: > I can only link to this  > > http://git.php.net/?p=php-src.git;a=commitdiff;h=ec78507bd46a05f77dbde3fa4091ab4c91e61cad > > the new implementation was consistent but had to be reverted in 7.1 > partially, because of BC, even the use is inappropriate.

RE: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Anatol Belski
> -Original Message- > From: Fleshgrinder [mailto:p...@fleshgrinder.com] > Sent: Friday, March 31, 2017 8:32 PM > To: Anatol Belski <a...@php.net>; internals@lists.php.net; Rasmus Schultz > <ras...@mindplay.dk> > Subject: Re: [PHP-DEV] Directory separators

Re: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Fleshgrinder
Hey :) On 3/31/2017 7:51 PM, Anatol Belski wrote: > Well, there was slightly more in your msg, thus the response  > Not really: On 3/30/2017 8:05 PM, Fleshgrinder wrote: > Windows and paths is a complicated and lengthy story. > > TL;DR all versions of Windows are able to deal with slashes,

RE: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Anatol Belski
> -Original Message- > From: Fleshgrinder [mailto:p...@fleshgrinder.com] > Sent: Friday, March 31, 2017 6:29 PM > To: Anatol Belski <a...@php.net>; internals@lists.php.net; Rasmus Schultz > <ras...@mindplay.dk> > Subject: Re: [PHP-DEV] Directory separators o

Re: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Fleshgrinder
On 3/31/2017 12:33 PM, Anatol Belski wrote: > Regarding the path variants support - it's not quite that way. PHP > streams abstract many things, for both simplicity and security. The > current state has historically grown on these two factors. So far I > can tell, the only what we don't support is

Re: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread S.A.N
> +1 > Can be used, for convert NAMESPACE to filepath in autoload ) > > > function __autoload($path) > { > include convert_seperators($path); > } > > > On Windows, it is what realpath does. > No, realpath() - is not used `include_path` -- PHP Internals - PHP Runtime Development Mailing

RE: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Anatol Belski
Hi, > -Original Message- > From: Fleshgrinder [mailto:p...@fleshgrinder.com] > Sent: Thursday, March 30, 2017 8:05 PM > To: Rasmus Schultz <ras...@mindplay.dk>; PHP internals > <internals@lists.php.net> > Subject: Re: [PHP-DEV] Directory separators on Win

Re: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Pierre Joye
On Fri, Mar 31, 2017 at 3:32 PM, Rasmus Schultz wrote: > Well, this is the opposite of what I'm asking for, and does not address the > case where paths have been persisted in a file or database and the data > gets accessed from different OS. > > I understand the reasons given

Re: [PHP-DEV] Directory separators on Windows

2017-03-31 Thread Rasmus Schultz
Well, this is the opposite of what I'm asking for, and does not address the case where paths have been persisted in a file or database and the data gets accessed from different OS. I understand the reasons given for not changing this behavior in PHP itself, so maybe we could have a standard

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Pierre Joye
On Mar 31, 2017 8:19 AM, "S.A.N" wrote: > Another option would be to create a function that converts all slashes in a > given input string to whatever the directory seperator should be on that > platform. This way, devs wouldn't have to deal with bulky aliases like >

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread S.A.N
> Another option would be to create a function that converts all slashes in a > given input string to whatever the directory seperator should be on that > platform. This way, devs wouldn't have to deal with bulky aliases like > DIRECTORY_SEPERATOR cluttering up their code. > > For example: > > >

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Fleshgrinder
On 3/30/2017 3:25 PM, Rasmus Schultz wrote: > Thoughts? > Windows and paths is a complicated and lengthy story. TL;DR all versions of Windows are able to deal with slashes, and we could easily use slashes everywhere all the time. # History The story why Windows is using the backslash might be

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Walter Parker
On Thu, Mar 30, 2017 at 8:21 AM, Sara Golemon wrote: > My first thought is UNC paths. On windows a file server share is > denoted by \\host\share . if you combine that with relative paths > produced from PHP, you end up in the dubious situation of > "\\host\share/path/to/file"

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Kris Craig
On Mar 30, 2017 8:21 AM, "Sara Golemon" wrote: > > My first thought is UNC paths. On windows a file server share is > denoted by \\host\share . if you combine that with relative paths > produced from PHP, you end up in the dubious situation of > "\\host\share/path/to/file" <---

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Sara Golemon
My first thought is UNC paths. On windows a file server share is denoted by \\host\share . if you combine that with relative paths produced from PHP, you end up in the dubious situation of "\\host\share/path/to/file" <--- wat? Overall, it smells of magic. -Sara On Thu, Mar 30, 2017 at 8:25 AM,

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Ryan Pallas
On Thu, Mar 30, 2017 at 8:05 AM, Rowan Collins wrote: > On 30 March 2017 14:25:02 BST, Rasmus Schultz wrote: > > >Returning backslashes on Windows seems rather unnecessary in the first > >place, since forward slashes work just fine? > > This may be

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Pierre Joye
On Mar 30, 2017 8:25 PM, "Rasmus Schultz" wrote: Today, I ran into a very hard-to-debug problem, in which paths (to SQL files, in a database migration script) were kept in a map, persisted to a JSON file, and this file was moved from a Windows to a Linux file-system - because

Re: [PHP-DEV] Directory separators on Windows

2017-03-30 Thread Rowan Collins
On 30 March 2017 14:25:02 BST, Rasmus Schultz wrote: >Returning backslashes on Windows seems rather unnecessary in the first >place, since forward slashes work just fine? This may be true when using the paths within PHP, but is it true outside of it? If your JSON file had

[PHP-DEV] Directory separators on Windows

2017-03-30 Thread Rasmus Schultz
Today, I ran into a very hard-to-debug problem, in which paths (to SQL files, in a database migration script) were kept in a map, persisted to a JSON file, and this file was moved from a Windows to a Linux file-system - because the paths on the Linux system had forward slashes, the files appeared