#!/usr/bin/env ruby

require 'ftools'

module FileCreation
  def create_timed_files(oldfile, newfile)
    return if File.exist?(oldfile) && File.exist?(newfile)
    old_time = create_file(oldfile)
    while create_file(newfile) <= old_time
      sleep(0.1)
      File.delete(newfile) rescue nil
    end
  end

  def create_file(name)
    open(name, "w") {|f| f.puts "HI" } if ! File.exist?(name)
    File.new(name).mtime
  end

  def delete_file(name)
    File.delete(name) rescue nil
  end
end


#!/usr/bin/env ruby

require 'ftools'

module FileCreation
  def create_timed_files(oldfile, newfile)
    return if File.exist?(oldfile) && File.exist?(newfile)
    old_time = create_file(oldfile)
    while create_file(newfile) <= old_time
      sleep(0.1)
      File.delete(newfile) rescue nil
    end
  end

  def create_file(name)
    dirname = File.dirname(name)
    FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
    open(name, "w") {|f| f.puts "HI" } unless File.exist?(name)
    File.new(name).mtime
  end

  def delete_file(name)
    File.delete(name) rescue nil
  end
end


Create directory in create_file if it does not exist.
Create directory in create_file if it does not exist.


git-svn-id: 6a2c20c72ceedae27ecedb68e90cd4f115192a7a@237 5af023f1-ac1a-0410-98d6-829a145c37ef
