On 3/17/06, bcorrigan78 / gmail.com <bcorrigan78 / gmail.com> wrote:
> Ok, well I figured out part of the issue.  The CSV file isn't being
> written before the Zlib call.  If I break this up into two scripts, the
> first that writes the file,  the second that zips it, things work.
>
> Any idea why the CSV file wouldn't be saved when the block ends?

The CSV::Writer::generate doesn't implicity close the file you've
opened in it's arguments.  This file is not closed until the script
exits, unless you explicity close the file, or open the file with a
block.  You might want to try something like:

CSV.open(tempfile,"w+", ',') do |csv|
     Find.find(dirname) do |f|
         csv << [File.dirname(f), File.basename(f), File.mtime(f).to_s]
     end
end

Note: I haven't tested the above, just looked at 'ri CSV.open'.

- Dimitri