Method: File.absolute_path?

Defined in:
file.c

.absolute_path?(file_name) ⇒ Boolean

Returns true if file_name is an absolute path, and false otherwise.

File.absolute_path?("c:/foo")     #=> false (on Linux), true (on Windows)

Returns:

  • (Boolean)


4114
4115
4116
4117
4118
4119
4120
4121
# File 'file.c', line 4114

static VALUE
s_absolute_path_p(VALUE klass, VALUE fname)
{
    VALUE path = rb_get_path(fname);

    if (!rb_is_absolute_path(RSTRING_PTR(path))) return Qfalse;
    return Qtrue;
}