English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
File Represents a connection to a normal file stdio An example of the class returned by open for a normal file.
Serial Number | Method & Description |
---|---|
1 | File::atime( path) Returns path the last access time. |
2 | File::basename( path[, suffix]) Returns path The filename at the end. If a suffixsuffix, it will be removed from the end of the filename. For example: File.basename("/home/users/bin/ruby.exe") #=> "ruby.exe" |
3 | File::blockdev?( path) Returns true if path is a block device. |
4 | File::chardev?( path) Returns true if path is a character device. |
5 | File::chmod( mode, path...) Changes the permission mode of the specified file. |
6 | File::chown( owner, group, path...) Changes the owner and group of the specified file. |
7 | File::ctime( path) Returns the last inode change time of path. |
8 | File::delete( path...) File::unlink( path...) Deletes the specified file. |
9 | File::directory?( path) Returns true if path is a directory. |
10 | File::dirname( path) Returns the directory part of path, excluding the final filename. |
11 | File::executable?( path) Returns true if path is executable. |
12 | File::executable_real?( path) Returns true if path is executable with real user permissions. |
13 | File::exist?( path) Returns true if path exists. |
1 | File::expand_path( path[, dir]) Returns the absolute path of path, where ~ is expanded to the home directory of the process owner, and ~user is expanded 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. |
14 | File::file?( path) Returns true if path is a regular file. |
15 | File::ftype( path) Returns one of the following strings to indicate the file type:
|
16 | File::grpowned?( path) Returns true if path is owned by the user's group. |
17 | File::join( item...) Returns a string, concatenating the specified items and separating them with File::Separator. For example: File::join("", "home", "usrs", "bin") # => "/home/usrs/bin" |
18 | File::link( old, new) Creates a hard link to the file old. |
19 | File::lstat( path) Same as stat, but it returns information on the symbolic link itself, not the file it points to. |
20 | File::mtime( path) Returns the last modification time of path. |
21 | File::new( path[, mode="r"]) File::open( path[, mode="r"]) File::open( path[, mode="r"]) {|f| ...} Opens a file. If a block is specified, execute the block by passing the new file as an argument. The file is automatically closed when the block exits. These methods differ from Kernel.open, even if path starts with |, the subsequent string will not be run as a command. |
22 | File::owned?( path) Returns true if path is owned by an effective user. |
23 | File::pipe?( path) Returns true if path is a pipe. |
24 | File::readable?( path) Returns true if path is readable. |
25 | File::readable_real?( path) Returns true if path is readable with real user permissions. |
25 | File::readlink( path) Returns the file pointed to by path. |
26 | File::rename( old, new) Change the filename old to new. |
27 | File::setgid?( path) If the set bit of path is set-group-Return true if the id permission bit is set. |
28 | File::setuid?( path) If the set bit of path is set-user-Return true if the id permission bit is set. |
29 | File::size( path) Return the file size of path. |
30 | File::size?( path) Return the file size of path, or nil if it is 0. |
31 | File::socket?( path) Return true if path is a socket. |
32 | File::split( path) Return an array containing the content of path, split into File::dirname(path) and File::basename(path). |
33 | File::stat( path) Return a File::Stat object with information on path. |
34 | File::sticky?( path) Return true if the sticky bit of path is set. |
35 | File::symlink( old, new) Create a symbolic link pointing to the file old. |
36 | File::symlink?( path) Return true if path is a symbolic link. |
37 | File::truncate( path, len) Truncate the specified file to len bytes. |
38 | File::unlink( path...) Delete the file given by path. |
39 | File::umask([ mask]) If no parameters are specified, return the current umask for this process. If a parameter is specified, set the umask and return the old umask. |
40 | File::utime( atime, mtime, path...) Change the access and modification time of the specified file. |
41 | File::writable?( path) Return true if path is writable. |
42 | File::writable_real?( path) Return true if path is writable through real user permissions. |
43 | File::zero?( path) Return true if the file size of path is 0. |
Assume f is File An example of a class:
Serial Number | Method & Description |
---|---|
1 | f.atime Return the last access time of f. |
2 | f.chmode(mode) Change the permission mode of f. |
3 | f.chown(owner, group) Change the owner and group of f. |
4 | f.ctime Return the last inode change time of f. |
5 | f.flock(op) Call flock().2).op can be 0 or a logical value or File class constants LOCK_EX, LOCK_NB, LOCK_SH, and LOCK_UN. |
6 | Call flock(). Same as stat, but it returns information on the symbolic link itself, not the file it points to. |
7 | f.mtime Return the last modification time of f. |
8 | f.path Return the pathname used to create f. |
9 | f.reopen(path[, mode="r"]) Reopen the file. |
10 | f.truncate(len) Truncate f to len bytes. |