diff options
Diffstat (limited to 'lib/efl/eet.rb')
-rw-r--r-- | lib/efl/eet.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/efl/eet.rb b/lib/efl/eet.rb index f66ede7..7a1ca5b 100644 --- a/lib/efl/eet.rb +++ b/lib/efl/eet.rb @@ -17,16 +17,22 @@ module Efl end private :initialize # - def self.open path, mode=:eet_file_mode_read, &blk - if blk - f = Efl::Eet.eet_open path, mode - raise Exception.new "Unable to open file #{path}" if f.nil? - yield REetFile.new f - Efl::Eet.eet_close f - else - f = Efl::Eet.eet_open path, mode - return REetFile.new f unless f.nil? - end + def self.open path, mode=:eet_file_mode_read + p = Efl::Eet.eet_open path, mode + raise Exception.new "Unable to open file #{path}" if p.nil? + o = REetFile.new FFI::AutoPointer.new p, REetFile.method(:release) + return o if not block_given? + yield o + o.close + nil + end + def self.release p + Efl::Eet.eet_close f + end + def close + @ptr.autorelease=false + Efl::Eet.eet_close @ptr + @ptr = nil end # def write key, data, compress=false |