From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Add a predicate for canonical file name Date: Tue, 13 Sep 2016 06:54:04 +0000 Message-ID: References: <838tux9h3c.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7ba97a10b2d7b0053c5e14ec X-Trace: blaine.gmane.org 1473749740 3755 195.159.176.226 (13 Sep 2016 06:55:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Sep 2016 06:55:40 +0000 (UTC) To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 13 08:55:33 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjhcy-0008VI-15 for ged-emacs-devel@m.gmane.org; Tue, 13 Sep 2016 08:55:32 +0200 Original-Received: from localhost ([::1]:46849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhcw-0005Xt-6T for ged-emacs-devel@m.gmane.org; Tue, 13 Sep 2016 02:55:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhcm-0005Xa-Kv for emacs-devel@gnu.org; Tue, 13 Sep 2016 02:55:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjhci-000064-FM for emacs-devel@gnu.org; Tue, 13 Sep 2016 02:55:19 -0400 Original-Received: from mail-wm0-f42.google.com ([74.125.82.42]:36214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhci-00005j-58 for emacs-devel@gnu.org; Tue, 13 Sep 2016 02:55:16 -0400 Original-Received: by mail-wm0-f42.google.com with SMTP id b187so170170409wme.1 for ; Mon, 12 Sep 2016 23:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=5TYa8MaFFSz8p7asx6Am0q92w8GM+DwuQI1Hyoh0hS0=; b=zbu49HUY31sJdLND4YTrqmJYvQyGQD+RQxoa9RBe5V9EdBOiWIIEPnh9Sxdlh9ZIts JIUHDGNXESvRLy+PizkTyGcOT5jaHGz/uSVhrqF8ODrQeBEnA4+oDhCP78SVcaoavOBP niybStec7QDTnVZoQ2FdOlHus0wx6TQnAHUgnc1ayfU1lKcCLiWxK/WlmMhT3pNd721w E5fj0p/jGlunJTr3hJmVd1pp7yjGn8zkt4gzxnc3BDBuraFv/1o5DeV1kcUOOoPoJ+l3 ElZlPG3AvMGRuA0Ip4K8TgEcQ8wLV82VJRHeDYWlJ7ll7Iog8J547wfVSuQIF1zuqTn/ j2Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=5TYa8MaFFSz8p7asx6Am0q92w8GM+DwuQI1Hyoh0hS0=; b=WRNukT2wc/AAbYUOioReEq0GRJ7asSQ5PXKvwlDwbFc7ZcEADqjtEKNwD0cZIQ0nRz rYTe9XiaW+lndlF7J9MMfxsbrrBPrzdyxTToUgqc/VSjSQ8x7o6/86raPpvZu+T4bDXb oglE33i4yspw6DO/jRbo850iFLA8hroKIg7fWbL8ITD8rYb2BWMORRovz25rBfMnyIFW sw7mykuwu9A/S6cwvIUnsik5XZjrROCFjEX7eKWkI5siLgibrKGI5QI/+oTul5yMBQ9D 3g/AWOkL2tx9J+RebzmVTBKtB/ujmzTbPaKam8HokjDsRfJ3BXt5vE5Y+gQkFmiqGUS3 sK0Q== X-Gm-Message-State: AE9vXwPK30zlD1AcSMJvzQXWOyNC/pwOegOMlXf3cQ4H3wI9T8T84La8v88/i0OoEMf977N5bJynzTgnAN5ccw== X-Received: by 10.194.184.39 with SMTP id er7mr18797288wjc.159.1473749655408; Mon, 12 Sep 2016 23:54:15 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.42 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207413 Archived-At: --047d7ba97a10b2d7b0053c5e14ec Content-Type: text/plain; charset=UTF-8 Stefan Monnier schrieb am Mo., 12. Sep. 2016 um 22:09 Uhr: > > Using string= here will cause false negatives, e.g. with Windows file > > names that use backslashes vs forward slashes, or due to letter-case > > differences on case-insensitive file systems. Did you really mean > > that? > > Indeed, such notions have already been requested and discussed here, and > it's not clear exactly what is needed and when. > > I can see several different meanings of "canonical", i.e. representative > member of an equivalence class (and I'd be inclined to prefer a function > that checks for "equivalence" between two file names rather than > a function that tries to find one canonical name). The equivalence > classes could be: > > - equivalent regardless of the actual on-disk data. I.e. this can't > take symlinks or hard links into account. Questions remain about > whether it could presume the "normal semantics of the most common > file-system". E.g. should it assume case-insensitive names in > MacOS/Windows and case-sensitive in GNU/Linux? > You couldn't even do that because case-folding on Windows depends on the file system. The only possibilities I see here are converting backslashes into slashes (or vice versa), and collapsing "//" and "/./". You couldn't even collapse "/../" because of symlinks. (Or you could ignore directory symlinks, as in https://golang.org/pkg/path/#Clean). > > - equivalent in practice for the current state of the file-system. > You can test this equivalence by comparing the output of > `file-attributes', except when the name corresponds to a file that > doesn't exist (yet?). > Like all filesystem operations, this easily introduces race conditions if decisions are made based on it: What might be an equivalent file name now (pointing to the same inode), might not be a nanosecond later. Over all, such an operation sounds more useful than it actually is. --047d7ba97a10b2d7b0053c5e14ec Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Stefan= Monnier <monnier@iro.umontr= eal.ca> schrieb am Mo., 12. Sep. 2016 um 22:09=C2=A0Uhr:
> Using string=3D here will cause false neg= atives, e.g. with Windows file
> names that use backslashes vs forward slashes, or due to letter-case > differences on case-insensitive file systems.=C2=A0 Did you really mea= n
> that?

Indeed, such notions have already been requested and discussed here, and it's not clear exactly what is needed and when.

I can see several different meanings of "canonical", i.e. represe= ntative
member of an equivalence class (and I'd be inclined to prefer a functio= n
that checks for "equivalence" between two file names rather than<= br class=3D"gmail_msg"> a function that tries to find one canonical name).=C2=A0 The equivalence classes could be:

- equivalent regardless of the actual on-disk data.=C2=A0 I.e. this can'= ;t
=C2=A0 take symlinks or hard links into account.=C2=A0 Questions remain abo= ut
=C2=A0 whether it could presume the "normal semantics of the most comm= on
=C2=A0 file-system".=C2=A0 E.g. should it assume case-insensitive name= s in
=C2=A0 MacOS/Windows and case-sensitive in GNU/Linux?

You couldn't even do that because ca= se-folding on Windows depends on the file system. The only possibilities I = see here are converting backslashes into slashes (or vice versa), and colla= psing "//" and "/./". You couldn't even collapse &q= uot;/../" because of symlinks. (Or you could ignore directory symlinks= , as in=C2=A0https://golang.= org/pkg/path/#Clean).
=C2=A0

- equivalent in practice for the current state of the file-system.
=C2=A0 You can test this equivalence by comparing the output of
=C2=A0 `file-attributes', except when the name corresponds to a file th= at
=C2=A0 doesn't exist (yet?).

Like all filesystem operations, this easil= y introduces race conditions if decisions are made based on it: What might = be an equivalent file name now (pointing to the same inode), might not be a= nanosecond later.
Over all, such an operation sounds more useful= than it actually is.=C2=A0
--047d7ba97a10b2d7b0053c5e14ec--