public static Verall Read(string path) { if (System.IO.File.Exists(System.IO.Path.Combine(path, "allver.ver.txt")) == false) { return(null); } string txt = System.IO.File.ReadAllText(System.IO.Path.Combine(path, "allver.ver.txt"), Encoding.UTF8); string[] lines = txt.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries); Verall var = new Verall(); foreach (var l in lines) { if (l.IndexOf("Ver:") == 0) { var.ver = int.Parse(l.Substring(4)); } else { var sp = l.Split('|'); var.groups[sp[0]] = new VerInfo(sp[0]); var.groups[sp[0]].Read(var.ver, sp[1], int.Parse(sp[2]), path); } } return(var); }
void InitVerAndPath() { ver = Verall.Read("./"); if(ver==null) { ver = new Verall(); string[] groups= System.IO.Directory.GetDirectories("./"); foreach(var g in groups) { string path = g.Substring(2).ToLower(); if (path.IndexOf("path") == 0) { continue; } ver.groups[path] = new VerInfo(path); } ver.ver = 0; } }
void InitVerAndPath() { ver = Verall.Read("./"); if (ver == null) { ver = new Verall(); string[] groups = System.IO.Directory.GetDirectories("./"); foreach (var g in groups) { string path = g.Substring(2).ToLower(); if (path.IndexOf("path") == 0) { continue; } ver.groups[path] = new VerInfo(path); } ver.ver = 0; } }
void GenVer() { if (vernew == null) { listBoxConsole.Items.Add("先检查一下版本再生成"); return; } else if (vernew.ver == ver.ver) { listBoxConsole.Items.Add("版本无变化"); //return; } vernew.SaveToPath("./"); listBoxConsole.Items.Add("生成OK Ver:" + vernew.ver); ver = vernew; listBoxGroup.Items.Clear(); foreach (var v in ver.groups) { listBoxGroup.Items.Add(v.Key); } }
void CheckVer() { vernew = new Verall(); string[] groups = System.IO.Directory.GetDirectories("./"); foreach (var g in groups) { string path = g.Substring(2).ToLower(); if (path.IndexOf("path") == 0) { continue; } if(ver.groups.ContainsKey(path)==false) { listBoxConsole.Items.Add("目录未包含:"+path+ " 如果需要增加,修改allver增加一行"); } } int delcount = 0; int updatecount = 0; int addcount = 0; foreach(var g in ver.groups) { vernew.groups[g.Key] = new VerInfo(g.Key); vernew.groups[g.Key].GenHash(); foreach(var f in g.Value.filehash) { if(vernew.groups[g.Key].filehash.ContainsKey(f.Key)==false) { listBoxConsole.Items.Add("文件被删除:" + g.Key+":"+f.Key); delcount++; } else { string hash= vernew.groups[g.Key].filehash[f.Key]; string oldhash = g.Value.filehash[f.Key]; if(hash!=oldhash) { listBoxConsole.Items.Add("文件更新:" + g.Key + ":" + f.Key); updatecount++; } } } foreach(var f in vernew.groups[g.Key].filehash) { if(g.Value.filehash.ContainsKey(f.Key)==false) { listBoxConsole.Items.Add("文件增加:" + g.Key + ":" + f.Key); addcount++; } } } if(addcount==0&&delcount==0&&updatecount==0) { vernew.ver = ver.ver; listBoxConsole.Items.Add("无变化 ver="+vernew.ver); } else { vernew.ver = ver.ver + 1; listBoxConsole.Items.Add("检查变化结果 add:" + addcount + " remove:" + delcount + " update:" + updatecount); listBoxConsole.Items.Add("版本号变为:" + vernew.ver); } //ver = vernew; }
void GenVer() { if(vernew==null) { listBoxConsole.Items.Add("先检查一下版本再生成"); return; } else if(vernew.ver==ver.ver) { listBoxConsole.Items.Add("版本无变化"); //return; } vernew.SaveToPath("./"); listBoxConsole.Items.Add("生成OK Ver:"+vernew.ver); ver = vernew; listBoxGroup.Items.Clear(); foreach (var v in ver.groups) { listBoxGroup.Items.Add(v.Key); } }
void CheckVer() { vernew = new Verall(); string[] groups = System.IO.Directory.GetDirectories("./"); foreach (var g in groups) { string path = g.Substring(2).ToLower(); if (path.IndexOf("path") == 0) { continue; } if (ver.groups.ContainsKey(path) == false) { listBoxConsole.Items.Add("目录未包含:" + path + " 如果需要增加,修改allver增加一行"); } } int delcount = 0; int updatecount = 0; int addcount = 0; foreach (var g in ver.groups) { vernew.groups[g.Key] = new VerInfo(g.Key); vernew.groups[g.Key].GenHash(); foreach (var f in g.Value.filehash) { if (vernew.groups[g.Key].filehash.ContainsKey(f.Key) == false) { listBoxConsole.Items.Add("文件被删除:" + g.Key + ":" + f.Key); delcount++; } else { string hash = vernew.groups[g.Key].filehash[f.Key]; string oldhash = g.Value.filehash[f.Key]; if (hash != oldhash) { listBoxConsole.Items.Add("文件更新:" + g.Key + ":" + f.Key); updatecount++; } } } foreach (var f in vernew.groups[g.Key].filehash) { if (g.Value.filehash.ContainsKey(f.Key) == false) { listBoxConsole.Items.Add("文件增加:" + g.Key + ":" + f.Key); addcount++; } } } if (addcount == 0 && delcount == 0 && updatecount == 0) { vernew.ver = ver.ver; listBoxConsole.Items.Add("无变化 ver=" + vernew.ver); } else { vernew.ver = ver.ver + 1; listBoxConsole.Items.Add("检查变化结果 add:" + addcount + " remove:" + delcount + " update:" + updatecount); listBoxConsole.Items.Add("版本号变为:" + vernew.ver); } //ver = vernew; }
public static Verall Read(string path) { if(System.IO.File.Exists(System.IO.Path.Combine(path, "allver.ver.txt"))==false) { return null; } string txt = System.IO.File.ReadAllText(System.IO.Path.Combine(path, "allver.ver.txt"),Encoding.UTF8); string[] lines = txt.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries); Verall var = new Verall(); foreach(var l in lines) { if(l.IndexOf("Ver:")==0) { var.ver = int.Parse(l.Substring(4)); } else { var sp= l.Split('|'); var.groups[sp[0]] = new VerInfo(sp[0]); var.groups[sp[0]].Read(var.ver,sp[1],int.Parse(sp[2]),path); } } return var; }