| Module | RIO::IF::Dir | lib/rio/if/dir.rb |
Calls ::Dir#chdir.
Changes the current working directory of the process to the directory specified by the Rio. Raises a SystemCallError (probably Errno::ENOENT) if the target directory does not exist or if the Rio does not reference a directory.
If a block is given changes to the directory specified by the rio for the length of the block and changes back outside the block
Returns the Rio
rio('/home').chdir # change the current working directory to /home
# the working directory here is /home
rio('/tmp/data/mydata').delete!.mkpath.chdir {
# the working directory here is /tmp/data/mydata
}
# the working directory here is /home
Calls Find#find
Uses ::Find#find to find all entries recursively for a Rio that specifies a directory. Note that there are other ways to recurse through a directory structure using a Rio. See each and all.
Calls the block passing a Rio for each entry found. The Rio inherits file attrubutes from the directory Rio.
Returns itself
rio('adir').find { |entrio| puts "#{entrio}: #{entrio.file?}" }
rio('adir').chomp.find do |entrio|
next unless entrio.file?
lines = entrio[0..10] # lines are chomped because 'chomp' was inherited
end
Calls ::Dir#glob
Returns the filenames found by expanding the pattern given in string, either as an array or as parameters to the block. In both cases the filenames are expressed as a Rio. Note that this pattern is not a regexp (it’s closer to a shell glob). See File::fnmatch for details of file name matching and the meaning of the flags parameter.
Calls FileUtils#mkdir
Makes a new directory named by the Rio with permissions specified by the optional parameter. The permissions may be modified by the value of File::umask
Returns the Rio. If the directory already exists, just returns the Rio.
rio('adir').mkdir
Calls FileUtils#mkpath
Makes a new directory named by the Rio and any directories in its path that do not exist.
Returns the Rio. If the directory already exists, just returns the Rio.
rio('adir/a/b').mkpath
Calls FileUtils#rmtree
Removes a directory Rio recursively. Returns the Rio. If the directory does not exist, simply returns the Rio
If called with a block, behaves as if rmtree.each(&block) had been called
See also delete!
rio('adir').rmtree # removes the directory 'adir' recursively
# delete the directory 'adir', recreate it and then change to the new directory
rio('adir/asubdir').rmtree.mkpath.chdir {
...
}
Copyright © 2005,2006,2007 Christopher Kleckner. All rights reserved.