Class

File

Extends:

ftools.rb: Extra tools for the File class

Author:WATANABE, Hirofumi
Documentation:Zachary Landau

This library can be distributed under the terms of the Ruby license. You can freely distribute/modify this library.

It is included in the Ruby standard library.

Description

ftools adds several (class, not instance) methods to the File class, for copying, moving, deleting, installing, and comparing files, as well as creating a directory path. See the File class for details.

FileUtils contains all or nearly all the same functionality and more, and is a recommended option over ftools

When you

require 'ftools'

then the File class aquires some utility methods for copying, moving, and deleting files, and more.

See the method descriptions below, and consider using FileUtils as it is more comprehensive.

Classes
Stat
Constants
BUFSIZE
Aliases
cmp
cp
mkpath
mv
o_chmod
rm_f
Public Methods
catname If to is a valid directory, from will be appended to to, adding and escaping backslashes as necessary. Otherwise, to will be returned. Useful for appending from to to only if the filename was not specified in to.
chmod Changes permission bits on files to the bit pattern represented by mode. If the last parameter isn’t a String, verbose mode will be enabled.
compare Returns true if and only if the contents of files from and to are identical. If verbose is true, from <=> to is printed.
copy Copies a file from to to using #syscopy. If to is a directory, copies from to to/from. If verbose is true, from -> to is printed.
install If src is not the same as dest, copies it and changes the permission mode to mode. If dest is a directory, destination is dest/src. If mode is not set, default is used. If verbose is set to true, the name of each file copied will be printed.
makedirs Creates a directory and all its parent directories. For example,
move Moves a file from to to using #syscopy. If to is a directory, copies from from to to/from. If verbose is true, from -> to is printed.
safe_unlink Removes a list of files. Each parameter should be the name of the file to delete. If the last parameter isn’t a String, verbose mode will be enabled. Returns the number of files deleted.
syscopy Copies a file from to to. If to is a directory, copies from to to/from.
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.