public int CompareTo(ICASCEntry other, int col, CASCEngine casc) { int result = 0; if (other is CASCFolder) { return(1); } switch (col) { case 0: result = Name.CompareTo(other.Name); break; case 1: result = Path.GetExtension(Name).CompareTo(Path.GetExtension(other.Name)); break; case 2: { var e1 = casc.RootHandler.GetEntries(Hash); var e2 = casc.RootHandler.GetEntries(other.Hash); var flags1 = e1.Any() ? e1.First().LocaleFlags : LocaleFlags.None; var flags2 = e2.Any() ? e2.First().LocaleFlags : LocaleFlags.None; result = flags1.CompareTo(flags2); } break; case 3: { var e1 = casc.RootHandler.GetEntries(Hash); var e2 = casc.RootHandler.GetEntries(other.Hash); var flags1 = e1.Any() ? e1.First().ContentFlags : ContentFlags.None; var flags2 = e2.Any() ? e2.First().ContentFlags : ContentFlags.None; result = flags1.CompareTo(flags2); } break; case 4: var size1 = GetSize(casc); var size2 = (other as CASCFile).GetSize(casc); if (size1 == size2) { result = 0; } else { result = size1 < size2 ? -1 : 1; } break; } return(result); }
private BinaryReader OpenInstallationFile(EncodingHandler encoding, CASCEngine engine, MD5Hash hash, string errorName) { EncodingEntry entry; if (!encoding.GetEntry(hash, out entry)) { throw new FileNotFoundException(string.Format("Installation missing {0} file!", errorName)); } return(new BinaryReader(engine.OpenFile(entry.Key))); }
public int CompareTo(ICASCEntry other, int col, CASCEngine casc) { int result = 0; if (other is CASCFolder) return 1; switch (col) { case 0: result = Name.CompareTo(other.Name); break; case 1: result = Path.GetExtension(Name).CompareTo(Path.GetExtension(other.Name)); break; case 2: { var e1 = casc.RootHandler.GetEntries(Hash); var e2 = casc.RootHandler.GetEntries(other.Hash); var flags1 = e1.Any() ? e1.First().LocaleFlags : LocaleFlags.None; var flags2 = e2.Any() ? e2.First().LocaleFlags : LocaleFlags.None; result = flags1.CompareTo(flags2); } break; case 3: { var e1 = casc.RootHandler.GetEntries(Hash); var e2 = casc.RootHandler.GetEntries(other.Hash); var flags1 = e1.Any() ? e1.First().ContentFlags : ContentFlags.None; var flags2 = e2.Any() ? e2.First().ContentFlags : ContentFlags.None; result = flags1.CompareTo(flags2); } break; case 4: var size1 = GetSize(casc); var size2 = (other as CASCFile).GetSize(casc); if (size1 == size2) result = 0; else result = size1 < size2 ? -1 : 1; break; } return result; }
public int CompareTo(ICASCEntry other, int col, CASCEngine casc) { int result = 0; if (other is CASCFile) return -1; switch (col) { case 0: case 1: case 2: case 3: result = Name.CompareTo(other.Name); break; case 4: break; } return result; }
public int CompareTo(ICASCEntry other, int col, CASCEngine casc) { int result = 0; if (other is CASCFile) { return(-1); } switch (col) { case 0: case 1: case 2: case 3: result = Name.CompareTo(other.Name); break; case 4: break; } return(result); }
public void LoadFileDataComplete(CASCEngine casc) { string dbFileDataComplete = "DBFilesClient\\FileDataComplete.db2"; if (!casc.FileExists(dbFileDataComplete)) return; Log.Write("CASC: Loading entries from FileDataComplete (DB2)"); using (var stream = casc.OpenFile(dbFileDataComplete)) { DB5_Reader db = new DB5_Reader(stream); foreach (var row in db) { string path = row.Value.GetField<string>(0); string name = row.Value.GetField<string>(1); string fullName = path + name; ulong fileHash = Hasher.ComputeHash(fullName); if (!RootData.ContainsKey(fileHash)) continue; CASCFile.FileNames[fileHash] = fullName; } } }
private BinaryReader OpenEncodingFile(CASCEngine casc) { return new BinaryReader(casc.OpenFile(casc.Config.EncodingKey)); }
private BinaryReader OpenInstallationFile(EncodingHandler encoding, CASCEngine engine, MD5Hash hash, string errorName) { EncodingEntry entry; if (!encoding.GetEntry(hash, out entry)) throw new FileNotFoundException(string.Format("Installation missing {0} file!", errorName)); return new BinaryReader(engine.OpenFile(entry.Key)); }
private BinaryReader OpenRootFile(EncodingHandler encoding, CASCEngine casc) { return OpenInstallationFile(encoding, casc, casc.Config.RootMD5, "root"); }
private BinaryReader OpenInstallFile(EncodingHandler encoding, CASCEngine casc) { return OpenInstallationFile(encoding, casc, casc.Config.InstallMD5, "install"); }
private BinaryReader OpenEncodingFile(CASCEngine casc) { return(new BinaryReader(casc.OpenFile(casc.Config.EncodingKey))); }
private BinaryReader OpenRootFile(EncodingHandler encoding, CASCEngine casc) { return(OpenInstallationFile(encoding, casc, casc.Config.RootMD5, "root")); }
private BinaryReader OpenDownloadFile(EncodingHandler encoding, CASCEngine casc) { return(OpenInstallationFile(encoding, casc, casc.Config.DownloadMD5, "download")); }
private BinaryReader OpenInstallFile(EncodingHandler encoding, CASCEngine casc) { return(OpenInstallationFile(encoding, casc, casc.Config.InstallMD5, "install")); }
public int GetSize(CASCEngine casc) { EncodingEntry entry; return casc.GetEncodingEntry(hash, out entry) ? entry.Size : 0; }
private BinaryReader OpenDownloadFile(EncodingHandler encoding, CASCEngine casc) { return OpenInstallationFile(encoding, casc, casc.Config.DownloadMD5, "download"); }
public int GetSize(CASCEngine casc) { EncodingEntry entry; return(casc.GetEncodingEntry(hash, out entry) ? entry.Size : 0); }