public string[] GenerateMapFilelist(MpqLib.Mpq.CArchive mpq) { string listcontent = ""; byte[] fc=new byte[999999]; mpq.ExportFile(@"(listfile)", fc); string[] filelist = System.Text.Encoding.ASCII.GetString(fc).Trim('\0').Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //StreamReader sr = new StreamReader("(listfile)"); //string[] filelist = sr.ReadToEnd().Trim().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < filelist.Length; i++) { if (Array.IndexOf(listdontwant, filelist[i].Trim().ToLower()) == -1) { listcontent += filelist[i] + "|"; } } return listcontent.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); }
public void Add(string filename, MpqLib.Mpq.CFileStream cfs) { setStatus(filename); byte[] buffer = new byte[cfs.Length]; cfs.Read(buffer, 0, (int)cfs.Length); TargetMPQ.ImportFile(filename, buffer); }
private void PackAllFileToMpq(string path, string basepath, MpqLib.Mpq.CArchive mpq) { DirectoryInfo dir = new DirectoryInfo(path); foreach (FileInfo fChild in dir.GetFiles("*")) //设置文件类型 { string mpqpath = fChild.FullName.Substring(fChild.FullName.IndexOf(basepath) + basepath.Length + 1); //string mpqpath = fChild.FullName.Replace(basepath + @"\", ""); mpq.ImportFile(mpqpath, fChild.FullName); } foreach (DirectoryInfo dChild in dir.GetDirectories("*")) //操作子目录 { PackAllFileToMpq(dChild.FullName, basepath, mpq); //递归 } }