static public void convertPrefix(string name) { if (System.IO.Directory.Exists(name)) { { // dir part string current = System.IO.Directory.GetCurrentDirectory(); string[] dirs = System.IO.Directory.GetDirectories(name); foreach (string dir in dirs) { if (IOController.validDirectory(dir)) { convertPrefix(dir); } } } { // file part string dname = System.IO.Path.GetFileName(name); dname = dname.ToLower(); if (dname == Path.Data.DialogDirectoryName || dname == Path.Data.MessageDirectoryName) { string[] files = System.IO.Directory.GetFiles(name); string mod = Path.Data.ModifiedDirectory; foreach (string file in files) { if (IOController.validDlgMesFile(file)) { int pos = file.IndexOf(mod); string outfile = file.Substring(pos + mod.Length); File prefix = new File(); prefix.open(file, false); prefix.addPrefixFileNumber(); //prefix.save( tempname ); prefix.save(Path.Data.TemporaryDirectory + outfile); // procは待機しないとデッドロックというより共有アクセス違反を起こす可能性大 // まともに動いても読み書きのタイミング次第では書き終わらないうちに前のファイルを誤読するはず // マルチで動いているのを確認 // tempディレクトリに一旦全部バリバリ書き出したほうが早いのかなあ //runConvertProcess( tempname, outfile, true ); runConvertProcess(Path.Data.TemporaryDirectory + outfile, Path.Data.ConvertedDirectory + outfile, false); } MainForm.incrementProgressBar(); } } } } }
static public void convert(string name) { if (System.IO.Directory.Exists(name)) { { // dir part string current = System.IO.Directory.GetCurrentDirectory(); string[] dirs = System.IO.Directory.GetDirectories(name); foreach (string dir in dirs) { if (IOController.validDirectory(dir)) { convert(dir); } } } { // file part string dname = System.IO.Path.GetFileName(name); dname = dname.ToLower(); if (dname == Path.Data.DialogDirectoryName || dname == Path.Data.MessageDirectoryName) { string[] files = System.IO.Directory.GetFiles(name); string mod = Path.Data.ModifiedDirectory; foreach (string file in files) { if (IOController.validDlgMesFile(file)) { int pos = file.IndexOf(mod); string outfile = file.Substring(pos + mod.Length); runConvertProcess(file, Path.Data.ConvertedDirectory + outfile, false); } MainForm.incrementProgressBar(); } } } } }
bool createFileTree(TreeNode node, string name) { bool find = false; { // dir part string current = System.IO.Directory.GetCurrentDirectory(); string[] dirs = System.IO.Directory.GetDirectories(name); int num = 0; foreach (string dir in dirs) { if (IOController.validDirectory(dir)) { ++num; } } if (num > 0) { TreeNode[] nodes = new TreeNode[num]; int count = 0; bool adding = false; for (int i = 0; i < dirs.Length; ++i) { // 存在確認したいが、再起なのでpathをつなげていかないと難しいな // あとaddrangeしてもnull混じりだとおちるかもしらんし if (IOController.validDirectory(dirs[i])) { string dir = System.IO.Path.GetFileName(dirs[i]); nodes[count] = new TreeNode(dir); nodes[count].ImageIndex = 0; nodes[count].SelectedImageIndex = 0; bool ret = createFileTree(nodes[count], dirs[i]); if (ret) { find = true; adding = true; } ++count; } } // 中にdlg,mesがあったら追加 if (adding) { node.Nodes.AddRange(nodes); } } } { // file part string[] files = System.IO.Directory.GetFiles(name); int num = 0; foreach (string file in files) { if (IOController.validDlgMesFile(file)) { num++; find = true; } } if (num > 0) { //Uri current = new Uri( Path.convineFullPath( Path.Data.BaseDirectory ) ); //TreeNode[] nodes = new TreeNode[ files.Length ]; TreeNode[] nodes = new TreeNode[num]; int count = 0; for (int i = 0; i < files.Length; ++i) { int icon = 1; if (IOController.validDlgMesFile(files[i])) { nodes[count] = new TreeNode(System.IO.Path.GetFileName(files[i])); string mod = Path.Data.ModifiedDirectory + files[i]; if (System.IO.File.Exists(mod)) { icon = 2; } else { icon = 1; } nodes[count].ImageIndex = icon; nodes[count].SelectedImageIndex = icon; ++count; } #if false nodes[i] = new TreeNode(System.IO.Path.GetFileName(files[i])); // 本当は進捗でやりたいのだが int icon = 1; // debug //File file = new File(); switch (ext.ToLower()) { case Path.Ext.MessageExtention: //icon = 1; //file.open( files[ i ], true ); //file.save( files[ i ] ); //System.Console.WriteLine( "|-" ); //System.Console.WriteLine( "| " + nodes[ i ].Text + " || || " ); //System.Console.WriteLine( "**" + nodes[ i ].Text ); //System.Console.WriteLine( " \"" + nodes[ i ].Text + "\" => \"" + System.IO.Path.GetDirectoryName( files[ i ] ) + "\"," ); find = true; break; case Path.Ext.DialogueExtention: //icon = 2; //file.open( files[ i ], true ); //file.save( files[ i ] ); //System.Console.WriteLine( "|-" ); //System.Console.WriteLine( "| " + nodes[ i ].Text + " || || " ); //System.Console.WriteLine( "**" + nodes[i].Text ); find = true; break; } //Uri uri = current.MakeRelativeUri( new Uri( files[ i ] ) ); //string mod = Path.convineFullPath( Path.Data.ModifiedDirectory + uri.ToString().Replace( '/', '\\' ) ); string mod = Path.Data.ModifiedDirectory + files[i]; if (System.IO.File.Exists(mod)) { icon = 2; } else { icon = 1; } nodes[i].ImageIndex = icon; nodes[i].SelectedImageIndex = icon; #endif } node.Nodes.AddRange(nodes); } else { node.Expand(); } return(find); } }
void calcProgress(string name, List <ProgressCount> progress, System.Collections.Hashtable ignore) { if (System.IO.Directory.Exists(name) == false) { return; } { // dir part string current = System.IO.Directory.GetCurrentDirectory(); string[] dirs = System.IO.Directory.GetDirectories(name); foreach (string dir in dirs) { if (IOController.validDirectory(dir)) { calcProgress(dir, progress, ignore); } } } { // file part string dname = System.IO.Path.GetFileName(name); dname = dname.ToLower(); if (dname == Path.Data.DialogDirectoryName || dname == Path.Data.MessageDirectoryName) { string[] files = System.IO.Directory.GetFiles(name); foreach (string file in files) { // 除外ファイル if (IOController.validDlgMesFile(file) && ignore.ContainsKey(file) == false) { File ori = new File(); ori.open(file, true); int num = 0; int idnum = ori.IDs.Count; string modpath = Path.Data.ModifiedDirectory + file; bool exist = System.IO.File.Exists(modpath); if (exist) { File mod = new File(); mod.open(modpath, false); int count = 0; // compair for (int i = 0; i < idnum; ++i) { string id = ori.IDs[i] as string; if (id != null) { File.Chunk oc = ori.Chunks[id] as File.Chunk; File.Chunk mc = mod.Chunks[id] as File.Chunk; if (oc != null && mc != null) { // この比較回数を削りたい if (ori.Type == File.FileType.MES) { File.Node omes = oc.Message; File.Node mmes = mc.Message; if (File.checkAvailable(omes.Original)) { ++count; if (omes.Original.CompareTo(mmes.Modify) != 0) { ++num; } } else { //++num; } } else { File.Node omale = oc.MaleLine; File.Node ofemale = oc.FemaleLine; File.Node mmale = mc.MaleLine; File.Node mfemale = mc.FemaleLine; // 二つあるしどういう条件にしようかなと 0.5? // 空はどうするかね // ある程度除外しないとあれだが、その辺はしょうがないのかねえ // だが[E:]みたいなのは、別ファイル参照なので除外してもいいかも // 男女別でカウント if (File.checkAvailable(omale.Original)) { if (omale.Original.CompareTo(mmale.Modify) != 0) { if (File.checkAvailable(ofemale.Original)) { ++count; if (ofemale.Original.CompareTo(mfemale.Modify) != 0) { ++num; } } else { //++num; } } } if (File.checkAvailable(ofemale.Original)) { ++count; if (ofemale.Original.CompareTo(mfemale.Modify) != 0) { ++num; } } else { //++num; } } } } } idnum = count; #if false if (num < idnum) { System.Console.WriteLine("\t" + modpath + ": " + num + " / " + idnum); } else { System.Console.WriteLine(modpath + ": " + num + " / " + idnum); } #endif } else { int count = 0; for (int i = 0; i < idnum; ++i) { string id = ori.IDs[i] as string; if (id != null) { File.Chunk oc = ori.Chunks[id] as File.Chunk; if (oc != null) { // この比較回数を削りたいのう if (ori.Type == File.FileType.MES) { File.Node omes = oc.Message; if (File.checkAvailable(omes.Original)) { ++count; } } else { File.Node omale = oc.MaleLine; File.Node ofemale = oc.FemaleLine; // 二つあるしどういう条件にしようかなと 0.5? // 空はどうするかね // ある程度除外しないとあれだが、その辺はしょうがないのかねえ // だが[E:]みたいなのは、別ファイル参照なので除外してもいいかも // 男女別でカウント if (File.checkAvailable(omale.Original)) { ++count; } if (File.checkAvailable(ofemale.Original)) { ++count; } #if false if (File.checkAvailable(omale.Original) || File.checkAvailable(ofemale.Original)) { ++count; } #endif } } } } idnum = count; } progress.Add(new ProgressCount(file, num, idnum, exist)); } else { //System.Console.WriteLine( "invalid format:" + file ); } incrementProgressBar(); } } } }