static public bool CompressKom(string dir, string filename) { if (System.IO.Directory.Exists(dir) == false) { return(false); } Komfile kom = new Komfile(); string[] files = System.IO.Directory.GetFiles(dir, "*", System.IO.SearchOption.AllDirectories); foreach (string file in files) { if (file.Contains(".svn\\") == false) { string key = System.IO.Path.GetFileName(file); if (kom.subfiles.ContainsKey(key) == false) { kom.Add(key, Kom2SubFile.ReadSubFileFromFile(file), true); } } } if (System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(filename)) == false) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filename)); } kom.Save(filename); kom.Close(); return(true); }
static public bool DecompressKom(string filename, string dir, string keystr) { if (System.IO.Directory.Exists(dir) == false) { if (System.IO.Directory.CreateDirectory(dir).Exists == false) { return(false); } } Komfile kom = new Komfile(); kom.SetECB(keystr); if (kom.Open(filename) == false) { return(false); } foreach (System.Collections.Generic.KeyValuePair <string, Kom2SubFile> KeyValue in kom.Subfiles) { System.IO.FileStream file = new System.IO.FileStream(System.IO.Path.Combine(dir, KeyValue.Key), System.IO.FileMode.Create, System.IO.FileAccess.Write); KeyValue.Value.WriteDecompressed(file); file.Close(); } kom.Close(); return(true); }
static public bool Equals(Komfile x, Komfile y) { if (x.Adler32 != y.Adler32 || x.HeaderSize != y.HeaderSize || x.FileTime != y.FileTime || x.Subfiles.Count != y.Subfiles.Count) { return(false); } foreach (System.Collections.Generic.KeyValuePair <string, Kom2SubFile> KeyValue in x.Subfiles) { if (y.Subfiles.ContainsKey(KeyValue.Key) == false) { return(false); } if (Kom2SubFile.Equals(KeyValue.Value, y.Subfiles[KeyValue.Key]) == false) { return(false); } } return(true); }