--- /dev/null
+# Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
+
+$LOAD_PATH.unshift("..")
+require "pathname"
+require "fileutils"
+require "chise/config"
+require "chise/util"
+require "chise/qp"
+
+module CHISE
+ class DataBaseManagement
+ def dump_all
+#CharDB.instance.dump_all()
+#CodesysDB.instance.dump_all()
+ end
+ end
+
+ class DataBaseFileManagement
+
+ # from specs/char-atr.ja.txt
+ OBSOLETE_FEATURES = "
+cns-radical
+cns-radical?
+kangxi-radical
+daikanwa-radical
+
+cns-strokes
+kangxi-strokes
+daikanwa-strokes
+shinjigen-1-radical
+gb-original-radical
+japanese-strokes
+jis-strokes-a
+jisx0208-strokes
+unicode-strokes
+
+cns-total-strokes
+
+non-morohashi
+
+=>ucs*
+#=>mojikyo
+#=mojikyo
+->identical
+
+ancient-ideograph-of
+ancient-char-of-shinjigen-1
+original-ideograph-of
+original-char-of-shinjigen-1
+vulgar-ideograph-of
+vulgar-char-of-shinjigen-1
+ideographic-variants
+variant-of-shinjigen-1
+
+iso-10646-comment
+".split
+
+ def initialize()
+ # @opt = {:noop=>true, :verbose=>true}
+ @opt = {:verbose=>true}
+ end
+
+ def move_obsolete_files
+ fpath = Config.instance.db_dir.path+"system-char-id"
+ fpath.chdir {
+ opath = "obsolete".path
+ opath.mkdir unless opath.directory?
+
+ OBSOLETE_FEATURES.each {|attr|
+ next if attr =~ /^#/
+ f = attr.path
+ f = f.normalize_filename
+ FileUtils.mv(f.to_s, opath.to_s, @opt) if f.exist?
+ f = f+".txt"
+ FileUtils.mv(f.to_s, opath.to_s, @opt) if f.exist?
+ }
+ }
+ end
+
+ def rename_files
+ path = Config.instance.db_dir.path
+
+ nfpath = path+"character/feature"
+ FileUtils.mkdir_p(nfpath.to_s, @opt) unless nfpath.directory?
+
+ fpath = path+"system-char-id"
+ fpath.each_entry {|f|
+ next if /\A\./ =~ f
+ FileUtils.mv((fpath+f).to_s, nfpath.to_s, @opt)
+ }
+
+ ncpath = path+"character/by_feature"
+ FileUtils.mkdir_p(ncpath.to_s, @opt) unless ncpath.directory?
+
+ path.each_entry {|f|
+ next if /\A\./ =~ f
+ next if f.to_s == "character"
+ d = path + f
+ next unless d.directory?
+ ff = d + "system-char-id"
+ if ff.exist?
+ FileUtils.mv(ff.to_s, (ncpath+f).to_s, @opt)
+ end
+ }
+ end
+ end
+end