Serial number Method and description 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 Assuming Serial number Method and description 1 F.atime returns the last access time of f. 2 3 4 F.ctime returns the last inode change time of f. 5 F.flock (op) calls flock (2). Op can be 0 or a logical value or File class constants LOCK_EX, LOCK_NB, LOCK_SH, and LOCK_UN. 6 F.lstat is the same as stat, but it returns information on its own symbolic link, not the file it points to. 7 F.mtime returns the last modification time of f. 8 F.path returns the pathname used to create f. 9 10
File
represents a connection to a normal file
stdio
object.
open
returns an instance of this class for a normal file. 6.28.1. Class method #
File::atime(
path)
returns the last access time of the path.
File::basename(
path[,
suffix])
Returns the file name at the end of the path. If suffix is specified, it is removed from the end of the file name. For example: File.basename (”/ home/users/bin/ruby.exe”) # = > “ruby.exe”
File::blockdev?(
path
returns true if path is a block device.
File::chardev?(
path)
returns true if path is a character device.
File::chmod(
mode,
path...)
changes the permission mode of the specifiedfile.
File::chown(
owner,
group,
path...)
changes the owner and group of the specified file.
File::ctime(
path)
returns the last inode change time of the path.
File::delete(
path...)
File::unlink(
path...)
deletes the specified file.
File::directory?(
path)
if path is a directory, true is returned.
File::dirname(
path)
returns the directory portion of the path, excluding the last file name.
File::executable?(
path)
returns true if path is executable.
File::executable_real?(
path)
if path is executable with true user rights, it returns true.
File::exist?(
path)
returns true if path exists.
File::expand_path(
path[,
dir])
return the absolute path of path, extend~ to the home directory of the process owner, and ~ user to the home directory of the user. The relative path is relative to the directory specified by dir, or to the current working directory if dir is omitted.
File::file?(
path)
if path is a normal file, true is returned.
File::ftype(
path)
returns one of the following strings, indicating the file type: file-normal file directory-directory characterSpecial-character special file blockSpecial-block special file fifo-named pipe (FIFO) link-symbolic link socket-Socket unknown-unknown file type
File::grpowned?(
path)
returns true if path is owned by the group to which the user belongs.
File::join(
item...)
returns a string concatenated by the specified items and uses the
File::Separator
to separate. For example: File::join (“”, “home”, “usrs”, “bin”) # = > “/ home/usrs/bin”
File::link(
old,
new)
create a hard link to the file old.
File::lstat(
path)
is the same as stat, but it returns information on its own symbolic link, not the file it points to.
File::mtime(
path)
returns the time when the path was last modified.
File::new(
path[,
mode="r"])
File::open(
path[,
mode="r"])
File::open(
path[,
mode="r"])
{|f|
...}
Open the file. If a block is specified, the block is executed by passing a new file as a parameter. When the block exits, the file closes automatically. These methods are different from Kernel.open in that even if path starts with | , subsequent strings are not run as commands.
File::owned?(
path)
returns true if path is owned by a valid user.
File::pipe?(
path)
returns true if path is a pipe.
File::readable?(
path)
returns true if path is readable.
File::readable_real?(
path)
if path is readable through true user rights, it returns true.
File::readlink(
path)
returns the file that path points to.
File::rename(
old,
new)
change the file name old to new.
File::setgid?(
path)
if the set-group-id permission bit of path is set, true is returned.
File::setuid?(
path)
if the set-user-id permission bit of path is set, true is returned.
File::size(
path)
Returns the file size of the path.
File::size?(
path)
Returns the file size of path, or nil if 0.
File::socket?(
path)
Returns true if path is a socket.
File::split(
path)
Returns an array containing the contents of path, andthe path is divided into
File::dirname(path)
and
File::basename(path)
.
File::stat(
path)
object with information on the path
File::Stat
object.
File::sticky?(
path)
Returns true if the sticky bit of path is set.
File::symlink(
old,
new)
Create a symbolic link to the file old.
File::symlink?(
path)
Returns true if path is a symbolic link.
File::truncate(
path,
len)
Truncate the specified file as len bytes.
File::unlink(
path...)
Deletes the file given by path.
File::umask([
mask])
If no parameter is specified, the current umask is returned for the process. If a parameter is specified, umask is set and the old umask is returned.
File::utime(
atime,
mtime,
path...)
Changes the access and modification time of the specified file.
File::writable?(
path)
Returns true if path is writable.
File::writable_real?(
path)
If path is writable with true user rights, true is returned.
File::zero?(
path)
Returns true if the file size of path is 0. 6.28.2. Example method #
f
is an instance of the `` File` class:
f.chmode(
mode)
Change the permission mode of f.
f.chown(
owner,
group)
Change the owner and group of f.
f.reopen(
path[,
mode="r"])
Reopen the file.
f.truncate(
len)
Truncate f to len bytes.