On 22/10/05, Dirk Meijer <hawkman.gelooft / gmail.com> wrote:
> now i have another question, is it possible to create a new directory,
> because when i try that with File.open("./newdir/file.html", 'w') it gives
> me an error.
> so is it possible?
> Dirk.
>
$ ri1.8 FileUtils
------------------------------------------------------- Class: FileUtils
     (no description...)
------------------------------------------------------------------------

[snip]

Instance methods:
-----------------
     cd, chdir, chmod, cmp, compare_file, compare_stream, copy,
     copy_entry, copy_file, copy_stream, cp, cp_r, fu_blksize,
     fu_check_options, fu_default_blksize, fu_each_src_dest,
     fu_each_src_dest0, fu_list, fu_lstat, fu_mkdir, fu_output_message,
     fu_same?, fu_stat, fu_stream_blksize, fu_update_option, getwd,
     have_st_ino?, identical?, install, link, ln, ln_s, ln_sf, makedirs,
     mkdir, mkdir_p, mkpath, move, mv, pwd, remove, remove_dir,
     remove_file, rm, rm_f, rm_r, rm_rf, rmdir, rmtree, safe_unlink,
     symlink, touch, uptodate?

$ ri1.8 FileUtils#mkdir
-------------------------------------------------------- FileUtils#mkdir
     mkdir(list, options = {})
------------------------------------------------------------------------
     Options: mode noop verbose

     Creates one or more directories.

       FileUtils.mkdir 'test'
       FileUtils.mkdir %w( tmp data )
       FileUtils.mkdir 'notexist', :noop => true  # Does not really create.
       FileUtils.mkdir 'tmp', :mode => 0700


$ irb
irb(main):001:0> require "fileutils"
=> true
irb(main):002:0> FileUtils.mkdir "test"
=> ["test"]
irb(main):003:0> File.open("test/t", "wb") do | f | f << "This is a test" end
=> #<File:test/t (closed)>
irb(main):004:0> File.read("test/t")
=> "This is a test"

$ rm -rf test

hope to help,

Brian

--
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/