summaryrefslogtreecommitdiffstats
path: root/lib/e17/eet.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/e17/eet.rb')
-rw-r--r--lib/e17/eet.rb58
1 files changed, 0 insertions, 58 deletions
diff --git a/lib/e17/eet.rb b/lib/e17/eet.rb
deleted file mode 100644
index 753588f..0000000
--- a/lib/e17/eet.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#! /usr/bin/env ruby
-# -*- coding: UTF-8 -*-
-#
-require 'e17/eet/eet-ffi'
-#
-module E17
- module Eet
- #
- class << self
- #
- def open path, mode=FILE_MODE_READ, &blk
- if blk
- f = E17::API.eet_open path, mode
- raise Exception.new "Unable to open file #{path}" if f.nil?
- yield EetFile.new f
- E17::API.eet_close f
- else
- f = E17::API.eet_open path, mode
- return EetFile.new f unless f.nil?
- end
- end
- end
- #
- class EetFile
- #
- def initialize ptr
- @ptr=ptr
- end
- private :initialize
- #
- def close
- E17::API.eet_close @ptr
- @ptr=nil
- end
- #
- def mode_get
- E17::API.eet_mode_get @ptr
- end
- #
- def write key, data, compress=false
- E17::API.eet_write @ptr, key, FFI::MemoryPointer.from_string(data), data.bytesize, ( compress ? 1 : 0 )
- end
- #
- def read key
- ptr = FFI::MemoryPointer.new(:int)
- data = E17::API.eet_read @ptr, key, ptr
- s = ptr.read_int
- ptr.free
- return nil if s==0
- ( data.null? ? nil : data.read_string[0..s-1] )
- end
- #
- end
- #
- end
-end
-#
-# EOF