From: eregontp@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92795] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
Date: Thu, 23 May 2019 12:04:20 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-78169.20190523120420.eaf7d1a2b9a5ddf4@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15868.20190523095313@ruby-lang.org
Issue #15868 has been updated by Eregon (Benoit Daloze).
`Pathname("C:/foo/bar").absolute?` should return `true` on Windows.
I think it does already:
https://github.com/ruby/ruby/blob/fe3ff5afb07e171fd950623c69abfbabbb2762a3/test/pathname/test_pathname.rb#L278-L282
On non-Windows platforms it will return `false`, which is correct for non-Windows platforms.
About `File.absolute_path?`, it sounds good to me.
----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78169
* Author: deivid (David Rodríguez)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Currently there's no way to check whether a path is absolute or not in a way that works accross OSs. The pathname library has the #absolute? method, but that only checks whether the path starts with a slash, which is not appropriate for Windows.
I thought of reimplementing it as something like File.absolute_path(self) == self, but that would mean accessing the filesystem, which I don't think we want here.
I also thought of implementing the "windows letter checks" in the pathname's library, but then I saw that those are already implemented in file.c, so I thought it would be a good idea to expose those. So I propose to add File.absolute_path? for this.
If this is accepted, I can do a follow-up PR to change Pathname#absolute? to delegate to File.absolute_path?.
What do you think?
I attach a patch to add `File.absolute_path?` here (I also opened a PR on Github: https://github.com/ruby/ruby/pull/2198).
---Files--------------------------------
0001-Add-File.absolute_path.patch (3.24 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
next prev parent reply other threads:[~2019-05-23 12:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
2019-05-23 9:53 ` [ruby-core:92794] [Ruby trunk Feature#15868] Implement `File.absolute_path?` deivid.rodriguez
2019-05-23 12:04 ` eregontp [this message]
2019-05-23 12:25 ` [ruby-core:92796] " deivid.rodriguez
2019-05-23 13:11 ` [ruby-core:92797] " nobu
2019-05-23 13:32 ` [ruby-core:92798] " shevegen
2019-05-23 14:07 ` [ruby-core:92801] " deivid.rodriguez
2019-05-23 22:51 ` [ruby-core:92807] " matthew
2019-05-25 12:48 ` [ruby-core:92840] " deivid.rodriguez
2019-08-29 5:58 ` [ruby-core:94646] [Ruby master " matz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-78169.20190523120420.eaf7d1a2b9a5ddf4@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).