ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:92794] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
@ 2019-05-23  9:53 ` deivid.rodriguez
  2019-05-23 12:04 ` [ruby-core:92795] " eregontp
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: deivid.rodriguez @ 2019-05-23  9:53 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been reported by deivid (David Rodríguez).

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868

* 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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92795] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [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
  2019-05-23 12:25 ` [ruby-core:92796] " deivid.rodriguez
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: eregontp @ 2019-05-23 12:04 UTC (permalink / raw)
  To: ruby-core

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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92796] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [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 ` [ruby-core:92795] " eregontp
@ 2019-05-23 12:25 ` deivid.rodriguez
  2019-05-23 13:11 ` [ruby-core:92797] " nobu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: deivid.rodriguez @ 2019-05-23 12:25 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by deivid (David Rodríguez).


Ouch!

I actually read the `Pathname` docs, which state:

* "However non-Unix pathnames are supported experimentally", in the main section.

* "It returns true if the pathname begins with a slash", in the `#pathname` docs. 

And assumed this didn't work on Windows.

If this is the case, I'm not too strong towards adding `File.absolute_path?` although it still seems handy and simple?

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78170

* 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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92797] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-05-23 12:25 ` [ruby-core:92796] " deivid.rodriguez
@ 2019-05-23 13:11 ` nobu
  2019-05-23 13:32 ` [ruby-core:92798] " shevegen
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: nobu @ 2019-05-23 13:11 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by nobu (Nobuyoshi Nakada).


> ```diff
> +      File.basename("/foo/bar\\baz").should == true

The method name is wrong, and `File.absolute_path?("/foo/bar")` should be false on Windows as it doesn't have the drive letter.

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78171

* 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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92798] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-05-23 13:11 ` [ruby-core:92797] " nobu
@ 2019-05-23 13:32 ` shevegen
  2019-05-23 14:07 ` [ruby-core:92801] " deivid.rodriguez
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: shevegen @ 2019-05-23 13:32 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by shevegen (Robert A. Heiler).


I have no particular pro/con opinion on the suggestion itself, but I should state that since Pathname was mentioned - I
myself use File.* related methods exclusively. I used to use pathname in the past but I sort of gave up on it eventually,
primarily because File.* seems to work just fine (and FileUtils); partially also because of having to do require 'pathname'
and my general impression that pathname is more clumsy to work with than File (but this is a subjective opinion). So this
comment from me here is mostly about pathname to File.* related methods - to me, in the current use cases, I could happily
use File.* but it would be unlikely for me to go back to when I used to use pathname.

So when File.* and Pathname is compared, I would like to point out that the way how ruby users use either of them may
be different rather than equal/synonymous. (I am not sure if this comment is very useful but I wanted to point this out
at the least once.)

Having said that, I personally have not had a need for File.absolute_path?() yet. I use File.absolute_path() a lot,
though, often because I have to deal/handle symlinks through ruby, including re-symlinking, removing old symlinks
etc....

I can say that this may be useful, but personally I honestly have not yet had a need for it.

As for the documentation - I guess it could easily be made more accurate or slightly lengthier in this case; I assume
that this may depend a lot on the operating system, since windows is mentioned here. Perhaps the documentation can
add a sentence about present windows support - I have worked only very little with windows, but the ruby code I write
tends to work very well on windows out of the box, without even me trying to do much at all (even ruby-gtk stuff
works on windows, which is pretty cool).

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78172

* 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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92801] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-05-23 13:32 ` [ruby-core:92798] " shevegen
@ 2019-05-23 14:07 ` deivid.rodriguez
  2019-05-23 22:51 ` [ruby-core:92807] " matthew
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: deivid.rodriguez @ 2019-05-23 14:07 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by deivid (David Rodríguez).

File 0001-Add-File.absolute_path.patch added

Thanks @nobu, I updated the patch! Copy-pasta... :|

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78175

* 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)
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92807] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-05-23 14:07 ` [ruby-core:92801] " deivid.rodriguez
@ 2019-05-23 22:51 ` matthew
  2019-05-25 12:48 ` [ruby-core:92840] " deivid.rodriguez
  2019-08-29  5:58 ` [ruby-core:94646] [Ruby master " matz
  8 siblings, 0 replies; 9+ messages in thread
From: matthew @ 2019-05-23 22:51 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by phluid61 (Matthew Kerwin).


Out of interest, how does it treat relative paths like `C:foo\bar`?

(Funny observation: according to Microsoft, `\foo\bar` is an absolute path in Windows, according to their definition of "absolute path")

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78181

* 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)
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:92840] [Ruby trunk Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-05-23 22:51 ` [ruby-core:92807] " matthew
@ 2019-05-25 12:48 ` deivid.rodriguez
  2019-08-29  5:58 ` [ruby-core:94646] [Ruby master " matz
  8 siblings, 0 replies; 9+ messages in thread
From: deivid.rodriguez @ 2019-05-25 12:48 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by deivid (David Rodríguez).


I added a couple more specs to check that in https://github.com/ruby/ruby/pull/2198/commits/d59a5c93dd4b20aa0898a24fab78a68a2cc84925, but I'm not sure where I can check whether they pass on Windows or not.

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-78222

* 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)
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:94646] [Ruby master Feature#15868] Implement `File.absolute_path?`
       [not found] <redmine.issue-15868.20190523095313@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2019-05-25 12:48 ` [ruby-core:92840] " deivid.rodriguez
@ 2019-08-29  5:58 ` matz
  8 siblings, 0 replies; 9+ messages in thread
From: matz @ 2019-08-29  5:58 UTC (permalink / raw)
  To: ruby-core

Issue #15868 has been updated by matz (Yukihiro Matsumoto).


Agreed.

Matz.

----------------------------------------
Feature #15868: Implement `File.absolute_path?`
https://bugs.ruby-lang.org/issues/15868#change-81244

* 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)
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>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-08-29  5:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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 ` [ruby-core:92795] " eregontp
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

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).