truncate 2

file.truncate(integer) â 0 Instance Public methods Truncates file to at most integer bytes. The file must be opened for writing. Not available on all platforms. f = File.new("out", "w") f.syswrite("1234567890") #=> 10 f.truncate(5) #=> 0 f.close() #=> nil File.size("out") #=> 5

to_path

file.path â filename Instance Public methods 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"

size 2

file.size â integer Instance Public methods Returns the size of file in bytes. File.new("testfile").size #=> 66

path 2

file.path â filename Instance Public methods 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"

mtime 2

file.mtime â time Instance Public methods Returns the modification time for file. File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003

lstat 2

file.lstat â stat Instance Public methods Same as IO#stat, but does not follow the last symbolic link. Instead, reports on the link itself. File.symlink("testfile", "link2test") #=> 0 File.stat("testfile").size #=> 66 f = File.new("link2test") f.lstat.size #=> 8 f.stat.size #=> 66

flock

file.flock(locking_constant) â 0 or false Instance Public methods Locks or unlocks a file according to locking_constant (a logical or of the values in the table below). Returns false if File::LOCK_NB is specified and the operation would otherwise have blocked. Not available on all platforms. Locking constants (in class File): LOCK_EX | Exclusive lock. Only one process may hold an | exclusive lock for a given file at a time. ----------+----------------------------------

ctime 2

file.ctime â time Instance Public methods Returns the change time for file (that is, the time directory information about the file was changed, not the file itself). Note that on Windows (NTFS), returns creation time (birth time). File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003

chown 2

file.chown(owner_int, group_int ) â 0 Instance Public methods Changes the owner and group of file to the given numeric owner and group id's. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file's group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Follows symbolic links. See also File#lchown. File.new("testfile").chown(502, 1000)

chmod 2

file.chmod(mode_int) â 0 Instance Public methods Changes permission bits on file to the bit pattern represented by mode_int. Actual effects are platform dependent; on Unix systems, see chmod(2) for details. Follows symbolic links. Also see File#lchmod. f = File.new("out", "w"); f.chmod(0644) #=> 0