public Form1(string [] args) { InitializeComponent(); foreach (string filename in args) { Kom2.NET.Komfile kom = new Kom2.NET.Komfile(); bool iskom = kom.Open(filename); kom.Close(); if (iskom) { OpenKom(filename); } } }
protected override void ExecuteTask() { if (System.IO.Directory.Exists(workdir) == false) { System.IO.Directory.CreateDirectory(workdir); } if (workdir.EndsWith("\\") == false) { workdir += "\\"; } workdir = workdir.ToLower(); // 마스터 디스크립터를 기록하자 // 알아먹기 쉽게 일단 xml로 System.Collections.ArrayList files = new System.Collections.ArrayList(); // 리스트 foreach (string path in System.IO.Directory.GetFiles(workdir, "*", System.IO.SearchOption.AllDirectories)) { if (path.Contains("\\.svn\\") == false && System.IO.Path.GetFileName(path).ToLower() != System.IO.Path.GetFileName(filename).ToLower()) { files.Add(path.ToLower().Replace(workdir, "")); } } System.Xml.XmlDocument desc = new System.Xml.XmlDocument(); if (System.IO.File.Exists(filename) == true) { desc.Load(filename); } else { desc.AppendChild(desc.CreateNode(System.Xml.XmlNodeType.XmlDeclaration, "", "")); } System.Xml.XmlElement patchinfo = (System.Xml.XmlElement)desc.SelectSingleNode("Patchinfo"); if (patchinfo == null) { patchinfo = desc.CreateElement("Patchinfo"); desc.AppendChild(patchinfo); } System.Xml.XmlElement revisions = (System.Xml.XmlElement)patchinfo.SelectSingleNode("Revisions"); if (revisions == null) { revisions = desc.CreateElement("Revisions"); patchinfo.AppendChild(revisions); } System.Xml.XmlElement packing = (System.Xml.XmlElement)revisions.SelectSingleNode("Packing"); if (packing == null) { packing = desc.CreateElement("Packing"); packing.SetAttribute("Revision", "0"); revisions.AppendChild(packing); } System.Xml.XmlElement client = (System.Xml.XmlElement)revisions.SelectSingleNode("Client"); if (client == null) { client = desc.CreateElement("Client"); client.SetAttribute("Revision", "0"); revisions.AppendChild(client); } System.Xml.XmlElement patcher = (System.Xml.XmlElement)revisions.SelectSingleNode("Patcher"); if (patcher == null) { patcher = desc.CreateElement("Patcher"); patcher.SetAttribute("Revision", "0"); revisions.AppendChild(patcher); } System.Xml.XmlElement patch = (System.Xml.XmlElement)revisions.SelectSingleNode("Patch"); if (patch == null) { patch = desc.CreateElement("Patch"); patch.SetAttribute("Revision", "0"); revisions.AppendChild(patch); } System.Xml.XmlElement filesnode = (System.Xml.XmlElement)patchinfo.SelectSingleNode("Files"); if (filesnode != null) { patchinfo.RemoveChild(filesnode); } filesnode = desc.CreateElement("Files"); patchinfo.AppendChild(filesnode); foreach (string path in files) { System.Xml.XmlElement file = desc.CreateElement("File"); System.IO.FileInfo fi = new System.IO.FileInfo(System.IO.Path.Combine(workdir, path)); file.SetAttribute("Name", path); file.SetAttribute("Size", fi.Length.ToString()); Kom2.NET.Komfile kom = new Kom2.NET.Komfile(); if (kom.Open(System.IO.Path.Combine(workdir, path)) == true) { file.SetAttribute("Checksum", string.Format("{0:x8}", kom.Adler32)); file.SetAttribute("FileTime", string.Format("{0:x8}", kom.FileTime)); kom.Close(); } else { file.SetAttribute("Checksum", string.Format("{0:x8}", Kom2.NET.AdlerCheckSum.GetAdler32(System.IO.Path.Combine(workdir, path)))); file.SetAttribute("FileTime", "0"); } filesnode.AppendChild(file); } if (System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(filename)) == false) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filename)); } desc.Save(filename); }