From: Jason Persampieri Date: 2002-12-04T09:20:53+09:00 Subject: Re: Creating directories with File.open Ah... I see that in the 'Standard Library' section now. Thanks. Out of curiosity... why wouldn't something like this be in by default? Not to mention, why wouldn't 'open' just do this automatically if File::CREAT is set? Jason --- Yukihiro Matsumoto wrote: > Hi, > > In message "Creating directories with File.open" > on 02/12/04, Jason Persampieri > writes: > > |I'm attempting to create a file within a directory > |structure that may or may not exist yet. > | > |File.open("tempdir/foo.txt","w") fails seemingly > |because the 'tempdir' directory does not yet exist. > > |Is this proper behavior? If the user wants to > create > |the FILE, why would File#open assume they wouldn't > |want to create the underlying directory as well? > | > |Is there another method that WOULD go ahead and > create > |the directory for me? > > Put > > require 'ftools' > File.mkpath "tempdir" > > or > > require 'fileutils' > FileUtils.mkpath "tempdir" > > before "open". > > matz. >