diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-02 16:40:52 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-02 16:40:52 +0200 |
commit | f7d729b57551913941d93aee88c8f34ecfd10dd0 (patch) | |
tree | 46ed0fd6c77f7fd35e11ee2b670ebecfeb734df1 /lib/efl/eet.rb | |
parent | e430180e652a77f05c6ca041d64d05297f14ee59 (diff) | |
download | ffi-efl-f7d729b57551913941d93aee88c8f34ecfd10dd0.zip ffi-efl-f7d729b57551913941d93aee88c8f34ecfd10dd0.tar.gz |
REetFile use AutoPointer
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 |