public RPakFile(RisenPakFilePart p) { _Native = p; _Container = p._Container; }
protected void _init(RisenPak _Cont) { _Container = _Cont; if (name.Length != 0) name = name.Remove(name.Length - 1, 1); nameCAP = name.ToUpper(); if (this is RisenPakDirectory && children != null) { children.Reverse(); } }
internal RisenPakDirectory(System.IO.BinaryReader bR, RisenPakFilePart P2, RisenPak Container) { base.name = string.Empty; base.parent = P2; int l = bR.ReadInt32(); if (l != 0) l++; base.name = new string(bR.ReadChars(l)); base.TimeCreated = bR.ReadInt64(); base.TimeLastAccessed = bR.ReadInt64(); base.TimeLastModified = bR.ReadInt64(); base.Attributes = (RisenPakAttributes)bR.ReadUInt32() | RisenPakAttributes.RisenPakAttribute_Packed; int count = bR.ReadInt32(); children = new List<RisenPakFilePart>(); for (int i = 0; i < count; i++) { RisenPakAttributes attrib = (RisenPakAttributes)bR.ReadUInt32(); if ((attrib & RisenPakAttributes.RisenPakAttribute_Directory) == RisenPakAttributes.RisenPakAttribute_Directory) children.Add(new RisenPakDirectory(bR, this, Container)); else children.Add(new RisenPakFile(bR, this, Container)); } _init(Container); }
internal RisenPakFile(System.IO.BinaryReader bR, RisenPakFilePart P, RisenPak Container) { base.name = string.Empty; base.parent = P; int l = bR.ReadInt32(); if (l != 0) l++; base.name = new string(bR.ReadChars(l)); offset = bR.ReadInt64(); base.TimeCreated = bR.ReadInt64(); base.TimeLastAccessed = bR.ReadInt64(); base.TimeLastModified = bR.ReadInt64(); base.Attributes = (RisenPakAttributes)bR.ReadUInt32() | RisenPakAttributes.RisenPakAttribute_Packed; encrypt = (RisenPakEncryption)bR.ReadUInt32(); Compression = (RisenPakCompression)bR.ReadUInt32(); compSize = bR.ReadInt32(); uncompSize = bR.ReadInt32(); m_Stream = null; _init(Container); }
public static void InitFileManager(D3DApplication a_App, string a_Basepath = null) { NotifyOnPhysicalWatch = true; g_pApp = a_App; API_Device D = a_App.Device; e_MatEffect = new EffectWrapper("matCombiner.fx", D); r_MatTarget = new RenderTarget(2048, 2048, 1, SlimDX.Direct3D11.BindFlags.RenderTarget, SlimDX.DXGI.Format.B8G8R8A8_UNorm, 1, SlimDX.Direct3D11.ResourceOptionFlags.None, D); D.Content.FileHandleCreator = getHandle; D.Content.RegisterMaterialLoader(new XmatLoader()); D.Content.RegisterModelLoader(new XMACLoader()); D.Content.RegisterModelLoader(new XMSHLoader()); D.Content.RegisterTextureLoader(new XIMGLoader()); string basePath2 = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Deep Silver\Risen\", "INSTALL_DIR", string.Empty) as string; if (basePath2 != null && Directory.Exists(basePath2)) {//registry based g_pGamepath = basePath2.Replace(@"\bin", @"\"); } else if(!string.IsNullOrEmpty(a_Basepath)) {//ini file based g_pGamepath = a_Basepath + @"\"; } else { var msg = "Couldn't find risen directory. Terminating"; SystemLog.Append(LogImportance.System, msg); SystemLog.Flush(); MessageBox.Show(msg); throw new Exception(); } m_Paks = new Dictionary<string, RisenPak>(); DirectoryInfo[] Ds = new DirectoryInfo[] { new DirectoryInfo(g_pGamepath + "/data/common"), new DirectoryInfo(g_pGamepath + "/data/compiled") }; for (int i = 0; i < Ds.Length; i++) { if (!Ds[i].Exists) continue; int n = -1; while (true) { string a = n.ToString().PadLeft(2, '0'); FileInfo[] Fs = Ds[i].GetFiles(n < 0 ? ("*.pak") : ("*.p" + a)); foreach (FileInfo f in Fs) { string key = Ds[i].Name + @"\" + f.Name.Replace(f.Extension, "") + (n < 0 ? "" : a); RisenPak val = new RisenPak(FileManager.GetFile(f.FullName), _Files, n >= 0); m_Paks.Add(key, val); } n++; if (Fs.Length == 0) break; } } m_Watcher.Path = g_pGamepath; m_Watcher.IncludeSubdirectories = true; m_Watcher.NotifyFilter = NotifyFilters.FileName; m_Watcher.Created += W_Created; m_Watcher.Deleted += W_Created; m_Watcher.Renamed += W_Created; m_Watcher.EnableRaisingEvents = true; initFinished = true; StdFileReader S = new StdFileReader(); Dictionary<string, EFile> _PhyFiles = new Dictionary<string, EFile>(); List<EFile> newFiles = new List<EFile>(); Stack<DirectoryInfo> Dirs = new Stack<DirectoryInfo>(); Dirs.Push(new DirectoryInfo(g_pGamepath + "/Data")); while (Dirs.Count != 0) { DirectoryInfo d = Dirs.Pop(); DirectoryInfo[] _d = d.GetDirectories(); FileInfo[] _f = d.GetFiles(); foreach (DirectoryInfo q0 in _d) Dirs.Push(q0); foreach (FileInfo q1 in _f) { string k = q1.Name.ToUpper(); if (!isArchiveExtension(q1)) { EFile e = new EFile(q1.FullName, S); if (_PhyFiles.ContainsKey(k)) { SystemLog.Append(LogImportance.System, "Two identical physical files found!"); throw new Exception("Two identical physical files found!"); } _PhyFiles.Add(k, e); if (!FileManager._PhyFiles.ContainsKey(k)) newFiles.Add(e); } } } FileManager._PhyFiles = _PhyFiles; List<EFile> tabfiles = new List<EFile>(); System.IO.StreamReader tr = new System.IO.StreamReader(g_pGamepath + "data\\ini\\loc.ini"); while (!tr.EndOfStream) { string l = tr.ReadLine(); while (!tr.EndOfStream && string.IsNullOrEmpty(l)) l = tr.ReadLine(); if (tr.EndOfStream) break; string prefix = tr.ReadLine().Replace("prefix=", ""), csv = tr.ReadLine().Replace("csv=", ""), bin = tr.ReadLine().Replace("bin=", ""); EFile a = GetFile(bin.Replace(@"#G3:/", "")); if (!a.IsOpenable) SystemLog.Append(LogImportance.Warning, "Tab file not found : " + a.Name); tabFile b = new tabFile(a); tab_files.Add(a.Name, b); tab_FilesPrefix.Add(prefix.ToLower(), b); } tr.Close(); }