X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fruby.git;a=blobdiff_plain;f=chise%2Flibchise_r.rb;h=d68c77600bfa7ac7b60c8171f0dd5e929b98235b;hp=f0556f038d4f96b26ae59a403b229f9957b669a7;hb=5f691f77eafbb6df3012966d053e9d8b39c6a3ff;hpb=2e6979dc4c575c1fcace46446e6a95aef346fe1b diff --git a/chise/libchise_r.rb b/chise/libchise_r.rb index f0556f0..d68c776 100755 --- a/chise/libchise_r.rb +++ b/chise/libchise_r.rb @@ -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)) }