public List <string> GetForlder(string originalPath, string name) { if (Directory.Exists(originalPath)) { List <string> alldir = new List <string>(); foreach (string Dir in Directory.GetDirectories(originalPath)) { if (Dir.Contains(name)) { alldir.Add(Dir); } List <string> fold = GetForlder(Dir, name); if (fold != null) { foreach (string dir in fold) { alldir.Add(dir); } fold.Clear(); } } return(alldir); } return(null); }
private string CacheDefaultGamePath() { string[] Dirs = Directory.GetDirectories(Path.GetDirectoryName(ProjectFile)); foreach (string Dir in Dirs) { Debug.WriteLine("Found dir " + Dir); if (Dir.Contains(@"Config")) { Debug.WriteLine("Potential config folder found, checking for Default inis"); string[] ConfigFiles = Directory.GetFiles(Dir); foreach (string ConfigFile in ConfigFiles) { if (ConfigFile.Contains(@"DefaultGame")) { Debug.WriteLine("Found DefaultGame.ini, caching and bailing out"); DefaultGameConfig = ConfigFile; break; } } if (DefaultGameConfig != "") { break; } } } return(DefaultGameConfig); }
private void CacheSourcePath() { string[] Dirs = Directory.GetDirectories(Path.GetDirectoryName(ProjectFile)); foreach (string Dir in Dirs) { if (Dir.Contains(@"Source")) { SourceDirectory = Dir; break; } } }
private void Direccion() { Dir = Application.ExecutablePath; Dir = Dir.Substring(0, Dir.LastIndexOf("\\") + 1); if (Dir.Contains("34Proyectos\\Spamer\\Spamer\\bin\\Debug")) { if (Dir.Contains("C:\\Users\\fe")) { Dir = Dir.Replace("Proyectos\\Spamer\\Spamer\\bin\\Debug", "Proyectos\\Ventacelulares"); } else { Dir = Dir.Replace("Proyectos\\Spamer\\Spamer\\bin\\Debug", "Proyectos\\SpamerFace C++"); } } }
/// <summary> /// Adds files from a specified directory to a dictionary of entries. /// </summary> /// <param name="EntryDir">The directory to scan for entries.</param> /// <param name="Filetype">A fully qualified lowercase filetype to scan for (can be empty).</param> /// <param name="Entries">The Dictionary to add entries to.</param> private static void AddFilesFromDir(string EntryDir, string Filetype, ref Dictionary <FAR3Entry, string> Entries) { string[] Dirs = Directory.GetDirectories(EntryDir); foreach (string Dir in Dirs) { if (Filetype != "") { if (Dir.Contains(Filetype)) { string[] Files = Directory.GetFiles(Dir); string[] SubDirs = Directory.GetDirectories(Dir); foreach (string Fle in Files) { if (Fle.Contains(".dat")) { FAR3Archive Archive = new FAR3Archive(Fle); Archive.ReadArchive(true); foreach (FAR3Entry Entry in Archive.GrabAllEntries()) { Entries.Add(Entry, Fle.Replace(GlobalSettings.Default.StartupPath, "")); } } else { FAR3Entry Entry = new FAR3Entry(); Entry.Filename = Fle.Replace(GlobalSettings.Default.StartupPath, ""); Entry.FileID = HelperFuncs.GetFileID(Entry); Entry.TypeID = HelperFuncs.GetTypeID(Path.GetExtension(Fle)); HelperFuncs.CheckCollision(Entry.FileID, Entries); //Ignore fonts to minimize the risk of ID collisions. if (!Entry.Filename.Contains(".ttf")) { if (!Entry.Filename.Contains(".ffn")) { Entries.Add(Entry, Entry.Filename); } } } } foreach (string SubDir in SubDirs) { Files = Directory.GetFiles(SubDir); foreach (string SubFle in Files) { if (SubFle.Contains(".dat")) { FAR3Archive Archive = new FAR3Archive(SubFle); Archive.ReadArchive(false); foreach (FAR3Entry Entry in Archive.GrabAllEntries()) { Entries.Add(Entry, SubFle.Replace(GlobalSettings.Default.StartupPath, "")); } } else { FAR3Entry Entry = new FAR3Entry(); Entry.Filename = SubFle.Replace(GlobalSettings.Default.StartupPath, ""); Entry.FileID = HelperFuncs.GetFileID(Entry); Entry.TypeID = HelperFuncs.GetTypeID(Path.GetExtension(SubFle)); HelperFuncs.CheckCollision(Entry.FileID, Entries); //Ignore fonts to minimize the risk of ID collisions. if (!Entry.Filename.Contains(".ttf")) { if (!Entry.Filename.Contains(".ffn")) { Entries.Add(Entry, Entry.Filename); } } } } } } } else //Filetype was empty, so just add all filetypes found... { string[] Files = Directory.GetFiles(Dir); string[] SubDirs = Directory.GetDirectories(Dir); foreach (string Fle in Files) { if (Fle.Contains(".dat")) { FAR3Archive Archive = new FAR3Archive(Fle); Archive.ReadArchive(true); foreach (FAR3Entry Entry in Archive.GrabAllEntries()) { Entries.Add(Entry, Fle.Replace(GlobalSettings.Default.StartupPath, "")); } } else { FAR3Entry Entry = new FAR3Entry(); Entry.Filename = Fle.Replace(GlobalSettings.Default.StartupPath, ""); Entry.FileID = HelperFuncs.GetFileID(Entry); Entry.TypeID = HelperFuncs.GetTypeID(Path.GetExtension(Fle)); HelperFuncs.CheckCollision((ulong)(((ulong)Entry.FileID) << 32 | ((ulong)(Entry.TypeID >> 32))), Entries); //Ignore fonts to minimize the risk of ID collisions. if (!Entry.Filename.Contains(".ttf")) { if (!Entry.Filename.Contains(".ffn")) { Entries.Add(Entry, Entry.Filename); } } } } foreach (string SubDir in SubDirs) { Files = Directory.GetFiles(SubDir); foreach (string SubFle in Files) { if (SubFle.Contains(".dat")) { FAR3Archive Archive = new FAR3Archive(SubFle); Archive.ReadArchive(true); foreach (FAR3Entry Entry in Archive.GrabAllEntries()) { Entries.Add(Entry, SubFle.Replace(GlobalSettings.Default.StartupPath, "")); } } else { FAR3Entry Entry = new FAR3Entry(); Entry.Filename = SubFle.Replace(GlobalSettings.Default.StartupPath, ""); Entry.FileID = HelperFuncs.GetFileID(Entry); Entry.TypeID = HelperFuncs.GetTypeID(Path.GetExtension(SubFle)); HelperFuncs.CheckCollision((ulong)(((ulong)Entry.FileID) << 32 | ((ulong)(Entry.TypeID >> 32))), Entries); //Ignore fonts to minimize the risk of ID collisions. if (!Entry.Filename.Contains(".ttf")) { if (!Entry.Filename.Contains(".ffn")) { Entries.Add(Entry, Entry.Filename); } } } } } } } }
/// <summary> /// This function searches through all the IFFs in the game to /// find chunks of the type specified by the user. /// </summary> private void ScanIFFs() { string ObjDataPath = "", HouseDataPath = ""; bool LookingForSprites = false; if (m_TSOPath != "" || TxtTSOPath.Text != "") { if (TxtChunkType.Text != "") { if (TxtChunkType.Text.Contains("SPR#") || TxtChunkType.Text.Contains("SPR2") || TxtChunkType.Text.Contains("DGRP")) { LookingForSprites = true; } string[] Dirs = Directory.GetDirectories(m_TSOPath); foreach (string Dir in Dirs) { if (Dir.Contains("objectdata")) { ObjDataPath = Dir; } if (Dir.Contains("housedata")) { HouseDataPath = Dir; } } string[] ObjDataDirs = Directory.GetDirectories(ObjDataPath); string[] HouseDataDirs = Directory.GetDirectories(HouseDataPath); foreach (string Dir in ObjDataDirs) { string[] Files = Directory.GetFiles(Dir); foreach (string ArchivePath in Files) { if (ArchivePath.Contains(".far")) { FARArchive Archive = new FARArchive(ArchivePath); List <KeyValuePair <string, byte[]> > ArchiveFiles = Archive.GetAllEntries(); foreach (KeyValuePair <string, byte[]> ArchiveFile in ArchiveFiles) { if (!LookingForSprites) { //Skip the OTFs in 'objotf.far'... if (ArchiveFile.Key.Contains(".iff")) { Iff IffFile; List <IffChunk> Chunks = new List <IffChunk>(); int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } else { Iff IffFile; int NumChunks = 0; if (ArchiveFile.Key.Contains(".spf") || ArchiveFile.Key.Contains(".wll") || ArchiveFile.Key.Contains(".flr")) { LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } } } else //The files in "objectdata\globals\" are not in a FAR archive... { //Some of the files in "objectdata\globals\" are *.otf files... if (ArchivePath.Contains(".iff")) { if (!LookingForSprites) { Iff IffFile = new Iff(ArchivePath); int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchivePath }); //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { Path.GetFileName(ArchivePath) }); IffInfo Info = new IffInfo(); Info.ArchivePath = ""; Info.IffName = IffFile.Path; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath), InfoList); } } } } } foreach (string Dir in HouseDataDirs) { string[] Files = Directory.GetFiles(Dir); if (Dir.Contains("walls") || Dir.Contains("floors")) { foreach (string ArchivePath in Files) { FARArchive Archive = new FARArchive(ArchivePath); List <KeyValuePair <string, byte[]> > ArchiveFiles = Archive.GetAllEntries(); foreach (KeyValuePair <string, byte[]> ArchiveFile in ArchiveFiles) { if (!LookingForSprites) { //Don't waste time scanning *.spf files if not looking for sprites... if (!ArchiveFile.Key.Contains(".spf")) { Iff IffFile; int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } else { if (ArchiveFile.Key.Contains(".spf") || ArchiveFile.Key.Contains(".wll") || ArchiveFile.Key.Contains(".flr")) { Iff IffFile; int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } } } } } } else { MessageBox.Show("Please specify a chunktype to search for!"); } } LblScanning.Invoke((MethodInvoker) delegate() { LblScanning.Text = "Done, found: " + TotalNumberOfChunksFound() + " chunks."; }); BtnAbort.Invoke((MethodInvoker) delegate() { BtnAbort.Visible = false; }); m_WorkerThread.Abort(); }