Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/flogger/ext/file.rb

Class Method Summary collapse

Class Method Details

.open_or_create(file, access) ⇒ Object

create a file if it doesn’t already exist



5
6
7
8
9
10
11
12
13
# File 'lib/flogger/ext/file.rb', line 5

def self.open_or_create(file, access)
    begin
        path = File.dirname(file)
        FileUtils.mkdir_p(path) unless File.exists?(file)
        File.open(file, access)
    rescue Exception => e
        $stderr.puts e.message
    end
end