update.
[chise/ruby.git] / chise / libchise_r.rb
index f0556f0..d68c776 100755 (executable)
@@ -16,11 +16,9 @@ module CHISE
       #dir = @location + subdir
       dir = DataSource::DB_DIR.path + subdir
       dir.each_entry {|f|
-       #p f
        next if f.to_s == "." || f.to_s == ".."
-       #next if f.to_s =~ /\.txt\Z/
-       #yield(f.unescape_win_filename.unescape.to_s)
-       yield(f.to_s)
+       next if f.to_s =~ /\.txt\Z/
+       yield(f.unescape_win_filename.unescape.to_s)
       }
     end
   end
@@ -81,6 +79,8 @@ module CHISE
       dbdir  = dir + cat + keytype
       path = dbdir + name.path.escape.escape_win_filename
 
+      #TODO: should make dir.
+
       if amask == BDB::RDONLY
        raise unless FileTest.exist?(path.to_s)
       end
@@ -130,10 +130,18 @@ module CHISE
 
       return true if @db
 
-      #qp @ds.location, @category, @keyvalue, @name, @access, @ds.modemask
       begin
-       @db = AttributeTable.new(@ds.location, @category, @keyvalue,
-                                @name, access, @ds.modemask)
+       db_dir = @ds.location
+       modemask = @ds.modemask
+      rescue
+       db_dir = CHISE::DataSource::DB_DIR.path
+       modemask = 0755
+      end
+
+      #qp db_dir, @category, @keyvalue, @name, @access, modemask
+      begin
+       @db = AttributeTable.new(db_dir, @category, @keyvalue,
+                                @name, access, modemask)
        return false if @db.nil?
        @access = access
       rescue => e
@@ -209,7 +217,11 @@ module CHISE
 
     def each_char
       setup_db
-      raise "@db is nil." if @db.nil?
+      if @db.nil?
+       #raise "@db is nil."+@name
+       p "@db is nil."+@name
+       return nil
+      end
       @db.each {|code_point, cid|
        yield(code_point, parse_c_string(cid))
       }