public Method

File.path

file.path  filename

Returns the pathname used to create file as a string. Does not normalize the name.

File.new("testfile").path               #=> "testfile"
File.new("/tmp/../tmp/xxx", "w").path   #=> "/tmp/../tmp/xxx"

Source Code

/*
*  call-seq:
*     file.path -> filename
*  
*  Returns the pathname used to create <i>file</i> as a string. Does
*  not normalize the name.
*     
*     File.new("testfile").path               #=> "testfile"
*     File.new("/tmp/../tmp/xxx", "w").path   #=> "/tmp/../tmp/xxx"
*     
*/

static VALUE
rb_file_path(obj)
   VALUE obj;
{
   OpenFile *fptr;

   fptr = RFILE(rb_io_taint_check(obj))->fptr;
   rb_io_check_initialized(fptr);
   if (!fptr->path) return Qnil;
   return rb_tainted_str_new2(fptr->path);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.