Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26123 invoked from network); 31 Mar 2017 09:40:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2017 09:40:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.49 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.213.49 mail-vk0-f49.google.com Received: from [209.85.213.49] ([209.85.213.49:35598] helo=mail-vk0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/01-11319-D142ED85 for ; Fri, 31 Mar 2017 04:40:45 -0500 Received: by mail-vk0-f49.google.com with SMTP id r69so84545872vke.2 for ; Fri, 31 Mar 2017 02:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LMqh75v3rHqtqXDOhU5VmfCrQnK0Q+LGDozrXoLpYvk=; b=uHvppPiadxCHftcKcC/3aBHmVRCq5foQbNLsj85CnUMCgdQf5CR0i74W/cBoJrMJgz 5s6qfRNvZLpZMMzD56z/Hxu+UkZHCQTpjcaPXnCmGabM0wqtdlFwh1JiZP9Wwm6MqZ5y e7eco8ZvRtFVgr1MWUG0jUP9ZujjQBAQcUExqV7LxeBaPgITVZDwpwv54lluVGKAuqZq /6vtkYpByV1YhQnL+cZgPehId89Kw9sxjJcTxrh7zzi5+xboFQkS+sBPg3PmLGSu8i/z lviZHh/XECKqXtv677YQFIv2jqzCRKy1cXhX7nD0RTnYa0pT/oYUaDLkO8FhSZY16Evq IhBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LMqh75v3rHqtqXDOhU5VmfCrQnK0Q+LGDozrXoLpYvk=; b=CK5wQFFqF6SjZhlpTnCh5t9wUlaJ1BG2N+eSHiU9lNpv9kVBe6jHpSiV7nTOa8tXXg Jj2fcXf1q1rbrwTqWQ75+rPeTtcEDuqfeja/FFFCs97D65enL4QtaNalM3l0toe0C50L jQtun9MVDr0MLdAUs6fhdTC1FXnYwSstXmLsfVZSr3EcgIpMlGXKi2A04exx7X/gOwrw 8jN9rC5ufNVI9u37BojFinqmcR6LI0DXoG1s6PEIf7Z8eWvza+sKvTUkgabqY8sO79XG 1NH3J0/JXYLH7y1li/mVLeZ51XO0jDYz2qLefVYuQALJe/SAhLq70oQMiPj+bd/N4IM2 G9WA== X-Gm-Message-State: AFeK/H3fQk9STqSGDSGL6HKEzq6tkw0i947tR83LloWBVQv5Trd7lk12cNvP0mdy5JlZXsxKqqwzNqYOg7KEug== X-Received: by 10.31.254.12 with SMTP id l12mr909262vki.161.1490953242712; Fri, 31 Mar 2017 02:40:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.91.84 with HTTP; Fri, 31 Mar 2017 02:40:42 -0700 (PDT) In-Reply-To: References: Date: Fri, 31 Mar 2017 16:40:42 +0700 Message-ID: To: Rasmus Schultz Cc: Kris Craig , Sara Golemon , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Directory separators on Windows From: pierre.php@gmail.com (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 for not changing this behavior in PHP > itself, so maybe we could have a standard function that normalizes paths to > forward slashes? e.g. basically: > > /** > * Normalize a filesystem path. > * > * On windows systems, replaces backslashes with forward slashes > * and ensures drive-letter in upper-case. > * > * @param string $path > * > * @return string normalized path > */ > function normalize_path( $path ) { > $path = str_replace('\\', '/', $path); > > return $path{1} === ':' > ? ucfirst($path) > : $path; > } Also ucfirst is useless (or any case operations). realpath goes further down by solving ugly things like \\\\\\\ or ////// (code concatenating paths without checking trailing /\. > At least WordPress, Drupal and probably most major CMS and frameworks have > this function or something equivalent. . Now I remember why they have to do that. realpath is not fully exposed in userland. virtual_file_ex should be used and provide the option to validate path or not. Right now realpath will fail if the path does not exist. I would suggest to expose this functionality/option and that will solve the need to implement such things in userland. ps: I discussed that long time with Dmitry and forgot to implement it, I take the blame for not having that in 7.x :) Cheers, Pierre