Bug #6947 » 0002-Documentation-for-Pathname.patch
ext/pathname/lib/pathname.rb | ||
---|---|---|
#
|
||
# For documentation, see class Pathname.
|
||
#
|
||
# <tt>pathname.rb</tt> is distributed with Ruby since 1.8.0.
|
||
#
|
||
require 'pathname.so'
|
||
... | ... | |
proc {|a, b| a == b}
|
||
end
|
||
# :startdoc:
|
||
if File::ALT_SEPARATOR
|
||
SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}"
|
||
... | ... | |
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
|
||
end
|
||
# :startdoc:
|
||
# chop_basename(path) -> [pre-basename, basename] or nil
|
||
def chop_basename(path)
|
||
base = File.basename(path)
|
||
... | ... | |
# removed. The filesystem is not accessed.
|
||
#
|
||
# If +consider_symlink+ is +true+, then a more conservative algorithm is used
|
||
# to avoid breaking symbolic linkages. This may retain more <tt>..</tt>
|
||
# to avoid breaking symbolic linkages. This may retain more +..+
|
||
# entries than absolutely necessary, but without accessing the filesystem,
|
||
# this can't be avoided. See #realpath.
|
||
# this can't be avoided.
|
||
#
|
||
# See Pathname#realpath.
|
||
#
|
||
def cleanpath(consider_symlink=false)
|
||
if consider_symlink
|
||
... | ... | |
end
|
||
#
|
||
# Clean the path simply by resolving and removing excess "." and ".." entries.
|
||
# Clean the path simply by resolving and removing excess +.+ and +..+ entries.
|
||
# Nothing more, nothing less.
|
||
#
|
||
def cleanpath_aggressive
|
||
... | ... | |
end
|
||
private :cleanpath_conservative
|
||
# #parent returns the parent directory.
|
||
# Returns the parent directory.
|
||
#
|
||
# This is same as <tt>self + '..'</tt>.
|
||
# This is same as <code>self + '..'</code>.
|
||
def parent
|
||
self + '..'
|
||
end
|
||
# #mountpoint? returns +true+ if <tt>self</tt> points to a mountpoint.
|
||
# Returns +true+ if +self+ points to a mountpoint.
|
||
def mountpoint?
|
||
begin
|
||
stat1 = self.lstat
|
||
... | ... | |
end
|
||
#
|
||
# #root? is a predicate for root directories. I.e. it returns +true+ if the
|
||
# Predicate method for root directories. Returns +true+ if the
|
||
# pathname consists of consecutive slashes.
|
||
#
|
||
# It doesn't access actual filesystem. So it may return +false+ for some
|
||
# It doesn't access the filesystem. So it may return +false+ for some
|
||
# pathnames which points to roots such as <tt>/usr/..</tt>.
|
||
#
|
||
def root?
|
||
... | ... | |
end
|
||
# Predicate method for testing whether a path is absolute.
|
||
#
|
||
# It returns +true+ if the pathname begins with a slash.
|
||
#
|
||
# p = Pathname.new('/im/sure')
|
||
# p.absolute?
|
||
# #=> true
|
||
#
|
||
# p = Pathname.new('not/so/sure')
|
||
# p.absolute?
|
||
# #=> false
|
||
def absolute?
|
||
!relative?
|
||
end
|
||
# The opposite of #absolute?
|
||
# The opposite of Pathname#absolute?
|
||
#
|
||
# It returns +false+ if the pathname begins with a slash.
|
||
#
|
||
# p = Pathname.new('/im/sure')
|
||
# p.relative?
|
||
# #=> false
|
||
#
|
||
# p = Pathname.new('not/so/sure')
|
||
# p.relative?
|
||
# #=> true
|
||
def relative?
|
||
path = @path
|
||
while r = chop_basename(path)
|
||
... | ... | |
# Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
|
||
# # yields "usr", "bin", and "ruby".
|
||
#
|
||
# Returns an Enumerator if no block was given.
|
||
#
|
||
# enum = Pathname.new("/usr/bin/ruby").each_filename
|
||
# # ... do stuff ...
|
||
# enum.each { |e| ... }
|
||
# # yields "usr", "bin", and "ruby".
|
||
#
|
||
def each_filename # :yield: filename
|
||
return to_enum(__method__) unless block_given?
|
||
_, names = split_names(@path)
|
||
... | ... | |
# #<Pathname:path/to/some>
|
||
# #<Pathname:path/to/some/file.rb>
|
||
#
|
||
# It doesn't access actual filesystem.
|
||
#
|
||
# This method is available since 1.8.5.
|
||
# It doesn't access the filesystem.
|
||
#
|
||
def descend
|
||
vs = []
|
||
... | ... | |
# #<Pathname:path/to>
|
||
# #<Pathname:path>
|
||
#
|
||
# It doesn't access actual filesystem.
|
||
#
|
||
# This method is available since 1.8.5.
|
||
# It doesn't access the filesystem.
|
||
#
|
||
def ascend
|
||
path = @path
|
||
... | ... | |
end
|
||
#
|
||
# Pathname#+ appends a pathname fragment to this one to produce a new Pathname
|
||
# object.
|
||
# Appends a pathname fragment to +self+ to produce a new Pathname object.
|
||
#
|
||
# p1 = Pathname.new("/usr") # Pathname:/usr
|
||
# p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
|
||
... | ... | |
private :plus
|
||
#
|
||
# Pathname#join joins pathnames.
|
||
# Joins the given pathnames onto +self+ to create a new Pathname object.
|
||
#
|
||
# <tt>path0.join(path1, ..., pathN)</tt> is the same as
|
||
# <tt>path0 + path1 + ... + pathN</tt>.
|
||
# path0 = Pathname.new("/usr") # Pathname:/usr
|
||
# path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
|
||
# # is the same as
|
||
# path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
|
||
# path0 == path1
|
||
# #=> true
|
||
#
|
||
def join(*args)
|
||
args.unshift self
|
||
... | ... | |
#
|
||
# Returns the children of the directory (files and subdirectories, not
|
||
# recursive) as an array of Pathname objects. By default, the returned
|
||
# pathnames will have enough information to access the files. If you set
|
||
# +with_directory+ to +false+, then the returned pathnames will contain the
|
||
# filename only.
|
||
# recursive) as an array of Pathname objects.
|
||
#
|
||
# By default, the returned pathnames will have enough information to access
|
||
# the files. If you set +with_directory+ to +false+, then the returned
|
||
# pathnames will contain the filename only.
|
||
#
|
||
# For example:
|
||
# pn = Pathname("/usr/lib/ruby/1.8")
|
||
... | ... | |
# pn.children(false)
|
||
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
|
||
#
|
||
# Note that the results never contain the entries <tt>.</tt> and <tt>..</tt> in
|
||
# Note that the results never contain the entries +.+ and +..+ in
|
||
# the directory because they are not children.
|
||
#
|
||
# This method has existed since 1.8.1.
|
||
#
|
||
def children(with_directory=true)
|
||
with_directory = false if @path == '.'
|
||
result = []
|
||
... | ... | |
# Iterates over the children of the directory
|
||
# (files and subdirectories, not recursive).
|
||
#
|
||
# It yields Pathname object for each child.
|
||
# By default, the yielded pathnames will have enough information to access the files.
|
||
# If you set +with_directory+ to +false+, then the returned pathnames will contain the filename only.
|
||
#
|
||
# By default, the yielded pathnames will have enough information to access
|
||
# the files.
|
||
#
|
||
# If you set +with_directory+ to +false+, then the returned pathnames will
|
||
# contain the filename only.
|
||
#
|
||
# Pathname("/usr/local").each_child {|f| p f }
|
||
# #=> #<Pathname:/usr/local/share>
|
||
... | ... | |
# # #<Pathname:src>
|
||
# # #<Pathname:man>
|
||
#
|
||
# Note that the results never contain the entries +.+ and +..+ in
|
||
# the directory because they are not children.
|
||
#
|
||
# See Pathname#children
|
||
#
|
||
def each_child(with_directory=true, &b)
|
||
children(with_directory).each(&b)
|
||
end
|
||
#
|
||
# #relative_path_from returns a relative path from the argument to the
|
||
# receiver. If +self+ is absolute, the argument must be absolute too. If
|
||
# +self+ is relative, the argument must be relative too.
|
||
# Returns a relative path from the given +base_directory+ to the receiver.
|
||
#
|
||
# #relative_path_from doesn't access the filesystem. It assumes no symlinks.
|
||
# If +self+ is absolute, then +base_directory+ must be absolute too.
|
||
#
|
||
# ArgumentError is raised when it cannot find a relative path.
|
||
# If +self+ is relative, then +base_directory+ must be relative too.
|
||
#
|
||
# This method has existed since 1.8.1.
|
||
# This method doesn't access the filesystem. It assumes no symlinks.
|
||
#
|
||
# ArgumentError is raised when it cannot find a relative path.
|
||
#
|
||
def relative_path_from(base_directory)
|
||
dest_directory = self.cleanpath.to_s
|
||
... | ... | |
class Pathname # * Find *
|
||
#
|
||
# Pathname#find is an iterator to traverse a directory tree in a depth first
|
||
# manner. It yields a Pathname for each file under "this" directory.
|
||
# Iterates over the directory tree in a depth first manner, yielding a
|
||
# Pathname for each file under "this" directory.
|
||
#
|
||
# Returns an enumerator if no block is given.
|
||
# Returns an Enumerator if no block is given.
|
||
#
|
||
# Since it is implemented by <tt>find.rb</tt>, <tt>Find.prune</tt> can be used
|
||
# to control the traversal.
|
||
# Since it is implemented by the standard library module Find, Find.prune can
|
||
# be used to control the traversal.
|
||
#
|
||
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
|
||
# current directory, not <tt>./</tt>.
|
||
# If +self+ is +.+, yielded pathnames begin with a filename in the
|
||
# current directory, not +./+.
|
||
#
|
||
# See Find.find
|
||
#
|
||
def find # :yield: pathname
|
||
return to_enum(__method__) unless block_given?
|
||
... | ... | |
class Pathname # * FileUtils *
|
||
# See <tt>FileUtils.mkpath</tt>. Creates a full path, including any
|
||
# intermediate directories that don't yet exist.
|
||
# Creates a full path, including any intermediate directories that don't yet
|
||
# exist.
|
||
#
|
||
# See FileUtils.mkpath and FileUtils.mkdir_p
|
||
def mkpath
|
||
require 'fileutils'
|
||
FileUtils.mkpath(@path)
|
||
nil
|
||
end
|
||
# See <tt>FileUtils.rm_r</tt>. Deletes a directory and all beneath it.
|
||
# Recursively deletes a directory, including all directories beneath it.
|
||
#
|
||
# See FileUtils.rm_r
|
||
def rmtree
|
||
# The name "rmtree" is borrowed from File::Path of Perl.
|
||
# File::Path provides "mkpath" and "rmtree".
|
ext/pathname/pathname.c | ||
---|---|---|
/*
|
||
* Create a Pathname object from the given String (or String-like object).
|
||
* If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
|
||
* If +path+ contains a NULL character (<tt>\0</tt>), an ArgumentError is raised.
|
||
*/
|
||
static VALUE
|
||
path_initialize(VALUE self, VALUE arg)
|
||
... | ... | |
return self;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* pathname.freeze -> obj
|
||
*
|
||
* Freezes this Pathname.
|
||
*
|
||
* See Object.freeze.
|
||
*/
|
||
static VALUE
|
||
path_freeze(VALUE self)
|
||
{
|
||
... | ... | |
return self;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* pathname.taint -> obj
|
||
*
|
||
* Taints this Pathname.
|
||
*
|
||
* See Object.taint.
|
||
*/
|
||
static VALUE
|
||
path_taint(VALUE self)
|
||
{
|
||
... | ... | |
return self;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* pathname.untaint -> obj
|
||
*
|
||
* Untaints this Pathname.
|
||
*
|
||
* See Object.untaint.
|
||
*/
|
||
static VALUE
|
||
path_untaint(VALUE self)
|
||
{
|
||
... | ... | |
}
|
||
/*
|
||
* Provides for comparing pathnames, case-sensitively.
|
||
* Provides a case-sensitive comparison operator for pathnames.
|
||
*
|
||
* Pathname.new('/usr') <=> Pathname.new('/usr/bin')
|
||
* #=> -1
|
||
* Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin')
|
||
* #=> 0
|
||
* Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN')
|
||
* #=> 1
|
||
*
|
||
* It will return +-1+, +0+ or +1+ depending on the value of the left argument
|
||
* relative to the right argument. Or it will return +nil+ if the arguments
|
||
* are not comparable.
|
||
*/
|
||
static VALUE
|
||
path_cmp(VALUE self, VALUE other)
|
||
... | ... | |
/*
|
||
* Return a pathname which is substituted by String#sub.
|
||
*
|
||
* path1 = Pathname.new('/usr/bin/perl')
|
||
* path1.sub('perl', 'ruby')
|
||
* #=> #<Pathname:/usr/bin/ruby>
|
||
*/
|
||
static VALUE
|
||
path_sub(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* Return a pathname which the extension of the basename is substituted by
|
||
* <i>repl</i>.
|
||
* Return a pathname with +repl+ added as a suffix to the basename.
|
||
*
|
||
* If self has no extension part, <i>repl</i> is appended.
|
||
* If self has no extension part, +repl+ is appended.
|
||
*
|
||
* Pathname.new('/usr/bin/shutdown').sub_ext('.rb')
|
||
* #=> #<Pathname:/usr/bin/shutdown.rb>
|
||
*/
|
||
static VALUE
|
||
path_sub_ext(VALUE self, VALUE repl)
|
||
... | ... | |
/* Facade for File */
|
||
/*
|
||
* Returns the real (absolute) pathname of +self+ in the actual
|
||
* filesystem not containing symlinks or useless dots.
|
||
* Returns the real (absolute) pathname for +self+ in the actual
|
||
* filesystem.
|
||
*
|
||
* Does not contain symlinks or useless dots, +..+ and +.+.
|
||
*
|
||
* All components of the pathname must exist when this method is
|
||
* called.
|
||
... | ... | |
/*
|
||
* Returns the real (absolute) pathname of +self+ in the actual filesystem.
|
||
* The real pathname doesn't contain symlinks or useless dots.
|
||
*
|
||
* Does not contain symlinks or useless dots, +..+ and +.+.
|
||
*
|
||
* The last component of the real pathname can be nonexistent.
|
||
*/
|
||
... | ... | |
* pathname.each_line(sep, limit [, open_args]) {|line| block } -> nil
|
||
* pathname.each_line(...) -> an_enumerator
|
||
*
|
||
* #each_line iterates over the line in the file. It yields a String object
|
||
* for each line.
|
||
*
|
||
* This method is availabel since 1.8.1.
|
||
* Iterates over each line in the file and yields a String object for each.
|
||
*/
|
||
static VALUE
|
||
path_each_line(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
* pathname.read([length [, offset]]) -> string
|
||
* pathname.read([length [, offset]], open_args) -> string
|
||
*
|
||
* See <tt>IO.read</tt>. Returns all data from the file, or the first +N+ bytes
|
||
* if specified.
|
||
* Returns all data from the file, or the first +N+ bytes if specified.
|
||
*
|
||
* See IO.read.
|
||
*
|
||
*/
|
||
static VALUE
|
||
... | ... | |
* call-seq:
|
||
* pathname.binread([length [, offset]]) -> string
|
||
*
|
||
* See <tt>IO.binread</tt>. Returns all the bytes from the file, or the first +N+
|
||
* if specified.
|
||
* Returns all the bytes from the file, or the first +N+ if specified.
|
||
*
|
||
* See IO.binread.
|
||
*
|
||
*/
|
||
static VALUE
|
||
... | ... | |
* pathname.readlines(limit [, open_args]) -> array
|
||
* pathname.readlines(sep, limit [, open_args]) -> array
|
||
*
|
||
* See <tt>IO.readlines</tt>. Returns all the lines from the file.
|
||
* Returns all the lines from the file.
|
||
*
|
||
* See IO.readlines.
|
||
*
|
||
*/
|
||
static VALUE
|
||
... | ... | |
* call-seq:
|
||
* pathname.sysopen([mode, [perm]]) -> fixnum
|
||
*
|
||
* See <tt>IO.sysopen</tt>.
|
||
* See IO.sysopen.
|
||
*
|
||
*/
|
||
static VALUE
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.atime</tt>. Returns last access time.
|
||
* call-seq:
|
||
* pathname.atime -> time
|
||
*
|
||
* Returns the last access time for the file.
|
||
*
|
||
* See File.atime.
|
||
*/
|
||
static VALUE
|
||
path_atime(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.ctime</tt>. Returns last (directory entry, not file) change time.
|
||
* call-seq:
|
||
* pathname.ctime -> time
|
||
*
|
||
* Returns the last change time, using directory information, not the file itself.
|
||
*
|
||
* See File.ctime.
|
||
*/
|
||
static VALUE
|
||
path_ctime(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.mtime</tt>. Returns last modification time.
|
||
* call-seq:
|
||
* pathname.mtime -> time
|
||
*
|
||
* Returns the last modified time of the file.
|
||
*
|
||
* See File.mtime.
|
||
*/
|
||
static VALUE
|
||
path_mtime(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.chmod</tt>. Changes permissions.
|
||
* call-seq:
|
||
* pathname.chmod -> integer
|
||
*
|
||
* Changes file permissions.
|
||
*
|
||
* See File.chmod.
|
||
*/
|
||
static VALUE
|
||
path_chmod(VALUE self, VALUE mode)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.lchmod</tt>.
|
||
* call-seq:
|
||
* pathname.lchmod -> integer
|
||
*
|
||
* Same as Pathname.chmod, but does not follow symbolic links.
|
||
*
|
||
* See File.lchmod.
|
||
*/
|
||
static VALUE
|
||
path_lchmod(VALUE self, VALUE mode)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.chown</tt>. Change owner and group of file.
|
||
* call-seq:
|
||
* pathname.chown -> integer
|
||
*
|
||
* Change owner and group of the file.
|
||
*
|
||
* See File.chown.
|
||
*/
|
||
static VALUE
|
||
path_chown(VALUE self, VALUE owner, VALUE group)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.lchown</tt>.
|
||
* call-seq:
|
||
* pathname.lchown -> integer
|
||
*
|
||
* Same as Pathname.chown, but does not follow symbolic links.
|
||
*
|
||
* See File.lchown.
|
||
*/
|
||
static VALUE
|
||
path_lchown(VALUE self, VALUE owner, VALUE group)
|
||
... | ... | |
* pathname.fnmatch(pattern, [flags]) -> string
|
||
* pathname.fnmatch?(pattern, [flags]) -> string
|
||
*
|
||
* See <tt>File.fnmatch</tt>. Return +true+ if the receiver matches the given
|
||
* pattern.
|
||
* Return +true+ if the receiver matches the given pattern.
|
||
*
|
||
* See File.fnmatch.
|
||
*/
|
||
static VALUE
|
||
path_fnmatch(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory",
|
||
* etc).
|
||
* call-seq:
|
||
* pathname.ftype -> string
|
||
*
|
||
* Returns "type" of file ("file", "directory", etc).
|
||
*
|
||
* See File.ftype.
|
||
*/
|
||
static VALUE
|
||
path_ftype(VALUE self)
|
||
... | ... | |
* call-seq:
|
||
* pathname.make_link(old)
|
||
*
|
||
* See <tt>File.link</tt>. Creates a hard link at _pathname_.
|
||
* Creates a hard link at _pathname_.
|
||
*
|
||
* See File.link.
|
||
*/
|
||
static VALUE
|
||
path_make_link(VALUE self, VALUE old)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.open</tt>. Opens the file for reading or writing.
|
||
* Opens the file for reading or writing.
|
||
*
|
||
* See File.open.
|
||
*/
|
||
static VALUE
|
||
path_open(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.readlink</tt>. Read symbolic link.
|
||
* Read symbolic link.
|
||
*
|
||
* See File.readlink.
|
||
*/
|
||
static VALUE
|
||
path_readlink(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.rename</tt>. Rename the file.
|
||
* Rename the file.
|
||
*
|
||
* See File.rename.
|
||
*/
|
||
static VALUE
|
||
path_rename(VALUE self, VALUE to)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.stat</tt>. Returns a <tt>File::Stat</tt> object.
|
||
* Returns a File::Stat object.
|
||
*
|
||
* See File.stat.
|
||
*/
|
||
static VALUE
|
||
path_stat(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.lstat</tt>.
|
||
* See File.lstat.
|
||
*/
|
||
static VALUE
|
||
path_lstat(VALUE self)
|
||
... | ... | |
* call-seq:
|
||
* pathname.make_symlink(old)
|
||
*
|
||
* See <tt>File.symlink</tt>. Creates a symbolic link.
|
||
* Creates a symbolic link.
|
||
*
|
||
* See File.symlink.
|
||
*/
|
||
static VALUE
|
||
path_make_symlink(VALUE self, VALUE old)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.truncate</tt>. Truncate the file to +length+ bytes.
|
||
* Truncates the file to +length+ bytes.
|
||
*
|
||
* See File.truncate.
|
||
*/
|
||
static VALUE
|
||
path_truncate(VALUE self, VALUE length)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.utime</tt>. Update the access and modification times.
|
||
* Update the access and modification times of the file.
|
||
*
|
||
* See File.utime.
|
||
*/
|
||
static VALUE
|
||
path_utime(VALUE self, VALUE atime, VALUE mtime)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.basename</tt>. Returns the last component of the path.
|
||
* Returns the last component of the path.
|
||
*
|
||
* See File.basename.
|
||
*/
|
||
static VALUE
|
||
path_basename(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.dirname</tt>. Returns all but the last component of the path.
|
||
* Returns all but the last component of the path.
|
||
*
|
||
* See File.dirname.
|
||
*/
|
||
static VALUE
|
||
path_dirname(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.extname</tt>. Returns the file's extension.
|
||
* Returns the file's extension.
|
||
*
|
||
* See File.extname.
|
||
*/
|
||
static VALUE
|
||
path_extname(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.expand_path</tt>.
|
||
* Returns the absolute path for the file.
|
||
*
|
||
* See File.expand_path.
|
||
*/
|
||
static VALUE
|
||
path_expand_path(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>File.split</tt>. Returns the #dirname and the #basename in an Array.
|
||
* Returns the #dirname and the #basename in an Array.
|
||
*
|
||
* See File.split.
|
||
*/
|
||
static VALUE
|
||
path_split(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.blockdev?</tt>.
|
||
* See FileTest.blockdev?.
|
||
*/
|
||
static VALUE
|
||
path_blockdev_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.chardev?</tt>.
|
||
* See FileTest.chardev?.
|
||
*/
|
||
static VALUE
|
||
path_chardev_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.executable?</tt>.
|
||
* See FileTest.executable?.
|
||
*/
|
||
static VALUE
|
||
path_executable_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.executable_real?</tt>.
|
||
* See FileTest.executable_real?.
|
||
*/
|
||
static VALUE
|
||
path_executable_real_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.exist?</tt>.
|
||
* See FileTest.exist?.
|
||
*/
|
||
static VALUE
|
||
path_exist_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.grpowned?</tt>.
|
||
* See FileTest.grpowned?.
|
||
*/
|
||
static VALUE
|
||
path_grpowned_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.directory?</tt>.
|
||
* See FileTest.directory?.
|
||
*/
|
||
static VALUE
|
||
path_directory_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.file?</tt>.
|
||
* See FileTest.file?.
|
||
*/
|
||
static VALUE
|
||
path_file_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.pipe?</tt>.
|
||
* See FileTest.pipe?.
|
||
*/
|
||
static VALUE
|
||
path_pipe_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.socket?</tt>.
|
||
* See FileTest.socket?.
|
||
*/
|
||
static VALUE
|
||
path_socket_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.owned?</tt>.
|
||
* See FileTest.owned?.
|
||
*/
|
||
static VALUE
|
||
path_owned_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.readable?</tt>.
|
||
* See FileTest.readable?.
|
||
*/
|
||
static VALUE
|
||
path_readable_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.world_readable?</tt>.
|
||
* See FileTest.world_readable?.
|
||
*/
|
||
static VALUE
|
||
path_world_readable_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.readable_real?</tt>.
|
||
* See FileTest.readable_real?.
|
||
*/
|
||
static VALUE
|
||
path_readable_real_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.setuid?</tt>.
|
||
* See FileTest.setuid?.
|
||
*/
|
||
static VALUE
|
||
path_setuid_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.setgid?</tt>.
|
||
* See FileTest.setgid?.
|
||
*/
|
||
static VALUE
|
||
path_setgid_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.size</tt>.
|
||
* See FileTest.size.
|
||
*/
|
||
static VALUE
|
||
path_size(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.size?</tt>.
|
||
* See FileTest.size?.
|
||
*/
|
||
static VALUE
|
||
path_size_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.sticky?</tt>.
|
||
* See FileTest.sticky?.
|
||
*/
|
||
static VALUE
|
||
path_sticky_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.symlink?</tt>.
|
||
* See FileTest.symlink?.
|
||
*/
|
||
static VALUE
|
||
path_symlink_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.writable?</tt>.
|
||
* See FileTest.writable?.
|
||
*/
|
||
static VALUE
|
||
path_writable_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.world_writable?</tt>.
|
||
* See FileTest.world_writable?.
|
||
*/
|
||
static VALUE
|
||
path_world_writable_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.writable_real?</tt>.
|
||
* See FileTest.writable_real?.
|
||
*/
|
||
static VALUE
|
||
path_writable_real_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>FileTest.zero?</tt>.
|
||
* See FileTest.zero?.
|
||
*/
|
||
static VALUE
|
||
path_zero_p(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
||
* Returns or yields Pathname objects.
|
||
*
|
||
* Pathname.glob("config/*.rb")
|
||
* #=> [#<Pathname:config/environment.rb>, #<Pathname:config/routes.rb>, ..]
|
||
*
|
||
* See Dir.glob.
|
||
*/
|
||
static VALUE
|
||
path_s_glob(int argc, VALUE *argv, VALUE klass)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
|
||
* Returns the current working directory as a Pathname.
|
||
*
|
||
* Pathname.getwd
|
||
* #=> #<Pathname:/home/zzak/projects/ruby>
|
||
*
|
||
* See Dir.getwd.
|
||
*/
|
||
static VALUE
|
||
path_s_getwd(VALUE klass)
|
||
... | ... | |
* Return the entries (files and subdirectories) in the directory, each as a
|
||
* Pathname object.
|
||
*
|
||
* The result contains just a filename which has no directory.
|
||
*
|
||
* The result may contain the current directory #<Pathname:.> and the parent
|
||
* directory #<Pathname:..>.
|
||
*
|
||
* If you don't want #<Pathname:.> and #<Pathname:..> and
|
||
* want directory, consider Pathname#children.
|
||
* The results contains just the names in the directory, without any trailing
|
||
* slashes or recursive look-up.
|
||
*
|
||
* pp Pathname.new('/usr/local').entries
|
||
* #=> [#<Pathname:share>,
|
||
... | ... | |
* # #<Pathname:sbin>,
|
||
* # #<Pathname:src>]
|
||
*
|
||
* The result may contain the current directory <code>#<Pathname:.></code> and
|
||
* the parent directory <code>#<Pathname:..></code>.
|
||
*
|
||
* If you don't want +.+ and +..+ and
|
||
* want directories, consider Pathname#children.
|
||
*/
|
||
static VALUE
|
||
path_entries(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>Dir.mkdir</tt>. Create the referenced directory.
|
||
* Create the referenced directory.
|
||
*
|
||
* See Dir.mkdir.
|
||
*/
|
||
static VALUE
|
||
path_mkdir(int argc, VALUE *argv, VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>Dir.rmdir</tt>. Remove the referenced directory.
|
||
* Remove the referenced directory.
|
||
*
|
||
* See Dir.rmdir.
|
||
*/
|
||
static VALUE
|
||
path_rmdir(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* See <tt>Dir.open</tt>.
|
||
* Opens the referenced directory.
|
||
*
|
||
* See Dir.open.
|
||
*/
|
||
static VALUE
|
||
path_opendir(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* Iterates over the entries (files and subdirectories) in the directory. It
|
||
* yields a Pathname object for each entry.
|
||
*
|
||
* This method has available since 1.8.1.
|
||
* Iterates over the entries (files and subdirectories) in the directory,
|
||
* yielding a Pathname object for each entry.
|
||
*/
|
||
static VALUE
|
||
path_each_entry(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* Removes a file or directory, using <tt>File.unlink</tt> or
|
||
* <tt>Dir.unlink</tt> as necessary.
|
||
* Removes a file or directory, using File.unlink if +self+ is a file, or
|
||
* Dir.unlink as necessary.
|
||
*/
|
||
static VALUE
|
||
path_unlink(VALUE self)
|
||
... | ... | |
}
|
||
/*
|
||
* create a pathname object.
|
||
*
|
||
* This method is available since 1.8.5.
|
||
* Creates a new Pathname object.
|
||
*/
|
||
static VALUE
|
||
path_f_pathname(VALUE self, VALUE str)
|
||
... | ... | |
}
|
||
/*
|
||
* == Pathname
|
||
*
|
||
* Pathname represents a pathname which locates a file in a filesystem.
|
||
* The pathname depends on OS: Unix, Windows, etc.
|
||
* Pathname library works with pathnames of local OS.
|
||
* However non-Unix pathnames are supported experimentally.
|
||
* Pathname represents the name of a file or directory on the filesystem,
|
||
* but not the file itself.
|
||
*
|
||
* The pathname depends on the Operating System: Unix, Windows, etc.
|
||
* This library works with pathnames of local OS, however non-Unix pathnames
|
||
* are supported experimentally.
|
||
*
|
||
* It does not represent the file itself.
|
||
* A Pathname can be relative or absolute. It's not until you try to
|
||
* reference the file that it even matters whether the file exists or not.
|
||
*
|
||
* Pathname is immutable. It has no method for destructive update.
|
||
*
|
||
* The value of this class is to manipulate file path information in a neater
|
||
* The goal of this class is to manipulate file path information in a neater
|
||
* way than standard Ruby provides. The examples below demonstrate the
|
||
* difference. *All* functionality from File, FileTest, and some from Dir and
|
||
* FileUtils is included, in an unsurprising way. It is essentially a facade for
|
||
* all of these, and more.
|
||
* difference.
|
||
*
|
||
* *All* functionality from File, FileTest, and some from Dir and FileUtils is
|
||
* included, in an unsurprising way. It is essentially a facade for all of
|
||
* these, and more.
|
||
*
|
||
* == Examples
|
||
*
|
||
... | ... | |
* === Core methods
|
||
*
|
||
* These methods are effectively manipulating a String, because that's
|
||
* all a path is. Except for #mountpoint?, #children, #each_child,
|
||
* #realdirpath and #realpath, they don't access the filesystem.
|
||
* all a path is. None of these access the file system except for
|
||
* #mountpoint?, #children, #each_child, #realdirpath and #realpath.
|
||
*
|
||
* - +
|
||
* - #join
|
- « Previous
- 1
- 2
- Next »