home PYTHONJAVA
 

Ruby File class and method

File represents an stdio object that is connected to a regular file. Open returns an instance of this class for a regular file.

class method

serial numbermethod & description
1File::atime( path)
Returns the last access time of path.
2File::basename( path[, suffix])
Returns the document name toward the finish of path. In the event that suffix is determined, it will be expelled from the finish of the document name.
For instance: File.basename("/home/clients/container/ruby.exe") #=> "ruby.exe"
3File::blockdev?( path)
Returns genuine if way is a square gadget.
4File::chardev?( path)
Returns genuine if way is a character gadget.
5File::chmod( mode, path...)
Change the authorization method of the predetermined record.
6File::chown( proprietor, gathering, path...)
Changes the proprietor and gathering of the predetermined record.
7File::ctime( path)
Returns the last inode change time of way.
8File::delete( path...)
File::unlink( path...)

Delete the predefined document.
9File::directory?( path)
Returns genuine if way is an index.
10File::dirname( path)
Returns the catalog part of way, barring the last document name.
11File::executable?( path)
Returns genuine if way is executable.
12File::executable_real?( path)
Returns genuine if way is executable by genuine client rights.
13File::exist?( path)
Returns genuine if way exists.
1File::expand_path( path[, dir])
Returns the supreme way of way, augmentation ~ is the procedure proprietor's home catalog , ~user is the client's home index. The relative way is in respect to the catalog determined by dir, with respect to the present working registry if dir is discarded.
14File::file?( path)
Returns genuine if way is an ordinary record.
15File::ftype( path)
Returns one of the accompanying strings speaking to the document type:
  • file - typical file
  • directory - directory
  • characterSpecial - Character unique file
  • blockSpecial - square unique file
  • fifo - Named Pipes (FIFO)
  • link - representative link
  • socket - Socket
  • unknown - Unknown document type
16File::grpowned?( path)
Returns genuine if way is possessed by the client's own gathering.
17File::join( item...)
Returns a string linked by the predefined thing and utilizations File ::Separator is isolated.
For instance: File::join("", "home", "usrs", "canister") # => "/home/usrs/bin"
18File::link( old, new)
Create a hard connect to the record old.
19File::lstat( path)
Same as detail, however it returns data all alone emblematic connection as opposed to indicating record.
20File::mtime( path)
Returns the last change time of way.
21File::new( path[, mode="r"])
File::open( path[, mode="r"])
File::open( path[, mode="r"]) {|f| ...}

Open the document. In the event that a square is indicated, the square is executed by passing another record as a parameter. At the point when the square leaves, the record is consequently shut. These techniques are not quite the same as Kernel.open, and regardless of whether way begins with |, consequent strings won't keep running as directions.
22File::owned?( path)
Returns genuine if way is possessed by a legitimate client.
23File::pipe?( path)
Returns genuine if way is a pipe.
24File::readable?( path)
Returns genuine if way is meaningful.
25File::readable_real?( path)
Returns genuine if way is discernible by genuine client rights.
25File::readlink( path)
Returns the record indicated by way.
26File::rename( old, new)
Change the record name old to new.
27File::setgid?( path)
Returns genuine if the set-aggregate id authorization bit of way is set.
28File::setuid?( path)
Returns genuine if the set-client id authorization bit of way is set.
29File::size( path)
Returns the document size of way.
30File::size?( path)
Returns the record size of way, or 0 on the off chance that it returns nil.
31File::socket?( path)
Returns genuine if way is an attachment.
32File::split( path)
restores an exhibit containing the substance of way, way is isolated into File::dirname(path) And File::basename(path).
33File::stat( path)
Returns a File::Stat object with data on way.
34File::sticky?( path)
Returns genuine if the sticky piece of way is set.
35File::symlink( old, new)
Create an emblematic connect to the document old.
36File::symlink?( path)
Returns genuine if way is an emblematic connection.
37File::truncate( way, len)
Truncate the predefined record to len bytes.
38File::unlink( path...)
Delete the document given by way.
39File::umask([ mask])
If no contention is determined, the current umask is returned for the procedure. On the off chance that a parameter is indicated, umask is set and the old umask is returned.
40File::utime( atime, mtime, path...)
Changes the entrance and adjustment time of the predefined record.
41File::writable?( path)
Returns genuine if way is writable.
42File::writable_real?( path)
Returns genuine if way is writable by genuine client rights.
43File::zero?( path)
Returns genuine if the record size of way is 0.

Instance method

Assume that f is an occasion of the File class:

serial numbermethod & description
1f.atime
Returns the last access time of f.
2f.chmode( mode)
Change the authorization method of f.
3f.chown( proprietor, group)
Change the proprietor and gathering of f.
4f.ctime
Returns the last inode change time of f.
5f.flock( op)
Call flock(2). Operation can be 0 or a consistent esteem or the File class constants LOCK_EX, LOCK_NB, LOCK_SH, and LOCK_UN.
6f.lstat
Same as detail, yet it returns data all alone representative connection, not the record it focuses to.
7f.mtime
Returns the last adjustment time of f.
8f.path
Returns the way name used to make f.
9f.reopen( path[, mode="r"])
Reopen the record.
10f.truncate( len)
Truncate f to len bytes.





welookups is optimized for learning.© welookups. 2018 - 2019 All Right Reserved and you agree to have read and accepted our term and condition.