# File lib/ole/storage/base.rb, line 40 def initialize arg, mode=nil, params={} params, mode = mode, nil if Hash === mode params = {:update_timestamps => true}.merge(params) @params = params # get the io object @close_parent, @io = if String === arg mode ||= 'rb' [true, open(arg, mode)] else raise ArgumentError, 'unable to specify mode string with io object' if mode [false, arg] end # do we have this file opened for writing? don't know of a better way to tell # (unless we parse the mode string in the open case) # hmmm, note that in ruby 1.9 this doesn't work anymore. which is all the more # reason to use mode string parsing when available, and fall back to something like # io.writeable? otherwise. @writeable = begin if mode IO::Mode.new(mode).writeable? else @io.flush # this is for the benefit of ruby-1.9 # generates warnings on jruby though... :/ if RUBY_PLATFORM != 'java' and @io.respond_to?(:syswrite) @io.syswrite('') end true end rescue IOError false end # silence undefined warning in clear @sb_file = nil # if the io object has data, we should load it, otherwise start afresh # this should be based on the mode string rather. @io.size > 0 ? load : clear end