Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98687 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71332 invoked from network); 30 Mar 2017 17:13:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2017 17:13:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=walterp@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=walterp@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.178 as permitted sender) X-PHP-List-Original-Sender: walterp@gmail.com X-Host-Fingerprint: 209.85.220.178 mail-qk0-f178.google.com Received: from [209.85.220.178] ([209.85.220.178:34291] helo=mail-qk0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/2B-10047-ABC3DD85 for ; Thu, 30 Mar 2017 12:13:30 -0500 Received: by mail-qk0-f178.google.com with SMTP id d10so46027480qke.1 for ; Thu, 30 Mar 2017 10:13:30 -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=ohXpPtlyfmGUiYVTU206+bQSlsFwH3Om4EB6syh6EIw=; b=Y9FiCyrmkH1avCzy893KU1pY+tRiXV0ydfYQ2FVCNtqdUe/7w4NwLa+w2uf0inWZyj SnJ7riK4fDn+diYmaolMwOzalRESPVLf3Hbvq2odkAF8sKH0rm0glVsnk3YmXUc8gFot isaeMjQWYnxH1eHuoE10k+TRLMe8UmNG8gO38maK8MP2n9dqICYoQwaOcGF4xX8BQsTf RIMpB1uC9uYoYPF3ClXVKOqjrfwLYdXmf5ixqTIy0DcnaaMpp45X/udiMitbIUlHakKY 6+s/OuPhuGzDHGN3IQNDPGtfOROKwu+oI3mbcsFDDgDhlm37DkOlmtk+TLm9uKQS15Ww rbUQ== 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=ohXpPtlyfmGUiYVTU206+bQSlsFwH3Om4EB6syh6EIw=; b=Joly09pfALQmAY9rsgg9Rc30q0ZrL8jQZsm5rvpbvwLCjqy+S7CpGDZc2U4PTb4MoO 5y1l278Lh+qNLrdxLCfTvHvNo8eu4p6W+s0lgFduIANbLqwtsW35UOKeX1E28elBCuAl ZbNPwX618iH5tEybVrlm5wWi5RzMasVCn2lHNouOm4LD98zdPUdn+xQsU7Dvod7EDdPu 1By+8Y72FldlXJR6msTzvhk6RydDLxOKG2mTs6fqEHCwUM5UGTDUXL86f+xXvjuQLDfs 3JEl9V1UFqFfAT+Cc7i+jiWjpz+CZxB8EBaCLOhd2v5eBx7pigqeLMbi6Mesk155QY7p 6yvw== X-Gm-Message-State: AFeK/H3Yu85mi4PYd1ZMH8H08Y4hpQGHgVG69NCWTtepivCeUdLWd+kZjiBgjKRNBUkeUc7k+tGDlFlJvWeWsg== X-Received: by 10.55.92.195 with SMTP id q186mr766048qkb.84.1490894007914; Thu, 30 Mar 2017 10:13:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.165.66 with HTTP; Thu, 30 Mar 2017 10:13:27 -0700 (PDT) In-Reply-To: References: Date: Thu, 30 Mar 2017 10:13:27 -0700 Message-ID: To: Sara Golemon Cc: Rasmus Schultz , PHP internals Content-Type: multipart/alternative; boundary=001a114e486cbdb6b8054bf5cf3f Subject: Re: [PHP-DEV] Directory separators on Windows From: walterp@gmail.com (Walter Parker) --001a114e486cbdb6b8054bf5cf3f Content-Type: text/plain; charset=UTF-8 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" <--- wat? > > Overall, it smells of magic. > > -Sara > > On Thu, Mar 30, 2017 at 8:25 AM, 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 the paths on the Linux system had forward slashes, the files > > appeared to be missing from the map. > > > > Related questions are very commonly asked by Windows users, indicating > that > > this is a common problem: > > > > http://stackoverflow.com/questions/14743548/php-on- > windows-path-comes-up-with-backward-slash > > http://stackoverflow.com/questions/5642785/php-a-good- > way-to-universalize-paths-across-oss-slash-directions > > http://stackoverflow.com/questions/6510468/is-there-a- > way-to-force-php-on-windows-to-provide-paths-with-forward-slashes > > > > The answers that are usually given (use DIRECTORY_SEPARATOR, use > > str_replace() etc.) is that by default you automatically get > cross-platform > > inconsistencies, and the workarounds end up complicating code everywhere, > > and sometimes lead to other (sometimes worse) portability problems. > > > > The problem is worsened by functions like glob() and the SPL > directory/file > > traversal objects also producing inconsistent results. > > > > Returning backslashes on Windows seems rather unnecessary in the first > > place, since forward slashes work just fine? > > > > Might I suggest changing this behavior, such that file-system paths are > > consistently returned with a forward slash? > > > > Though this is more likely to fix rather than create issues, this could > be > > a breaking change in some cases, so there should probably be an INI > setting > > that enables the old behavior. > > > > Thoughts? > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > UNC pathing also works with forward slashes. For example, in powershell the following is valid and works if your host is named UNC1 and you have admin rights to the server. //UNC1/C$/ -- The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. -- Justice Louis D. Brandeis --001a114e486cbdb6b8054bf5cf3f--