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 th=
e 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 Fi=
le (but this is a subjective opinion). So this
comment from me here is mostly about pathname to File.* related methods - t=
o 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 i=
s 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, includin=
g re-symlinking, removing old symlinks
etc....

I can say that this may be useful, but personally I honestly have not yet h=
ad 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 mentio=
ned here. Perhaps the documentation can
add a sentence about present windows support - I have worked only very litt=
le with windows, but the ruby code I write
tends to work very well on windows out of the box, without even me trying t=
o 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=EDguez)
* Status: Open
* Priority: Normal
* Assignee: =

* Target version: =

----------------------------------------
Currently there's no way to check whether a path is absolute or not in a wa=
y that works accross OSs. The pathname library has the #absolute? method, b=
ut that only checks whether the path starts with a slash, which is not appr=
opriate for Windows.

I thought of reimplementing it as something like File.absolute_path(self) =
=3D=3D self, but that would mean accessing the filesystem, which I don't th=
ink 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? t=
o 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 G=
ithub: 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=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>