private static Task AddFilesToPackage(Package package, string path, string dataRootPath, string outputPath, List <string> ignoredFiles, CancellationToken token) { Task task = null; task = Task.Run(() => { if (!path.EndsWith(Path.DirectorySeparatorChar.ToString())) { path += Path.DirectorySeparatorChar; } AppController.Main.UpdateProgressLog("Enumerating files..."); var files = Directory.EnumerateFiles(path, DirectoryEnumerationOptions.Recursive | DirectoryEnumerationOptions.LargeCache, new DirectoryEnumerationFilters() { InclusionFilter = (f) => { return(!ignoredFiles.Any(x => IgnoreFile(f.FullPath, x))); } }).ToDictionary(k => k.Replace(dataRootPath, String.Empty), v => v); foreach (KeyValuePair <string, string> file in files) { if (token.IsCancellationRequested) { throw new TaskCanceledException(task); } FilesystemFileInfo fileInfo = FilesystemFileInfo.CreateFromEntry(file.Value, file.Key); package.Files.Add(fileInfo); } }, token); return(task); }
private void DiscoverModDirectory(string modName, string modPath) { DiscoverModGoals(modName, modPath); if (CollectNames) { DiscoverModGlobals(modName, modPath); DiscoverModLevelObjects(modName, modPath); } if (!LoadPackages) { var headerPath = modPath + @"\Story\RawFiles\story_header.div"; if (File.Exists(headerPath)) { var fileInfo = new FilesystemFileInfo { FilesystemPath = headerPath, Name = headerPath }; StoryHeaderFile = fileInfo; } } var orphanQueryIgnoresPath = modPath + @"\Story\story_orphanqueries_ignore_local.txt"; if (File.Exists(orphanQueryIgnoresPath)) { var fileInfo = new FilesystemFileInfo { FilesystemPath = orphanQueryIgnoresPath, Name = orphanQueryIgnoresPath }; GetMod(modName).OrphanQueryIgnoreList = fileInfo; } }
private void DiscoverModLevelObjects(string modName, string modPath) { var levelsPath = modPath + @"\Levels"; if (!Directory.Exists(levelsPath)) { return; } List <string> levelFiles = new List <string>(); EnumerateFiles(levelFiles, levelsPath, levelsPath, "*.lsf"); var levelObjectsRe = new Regex("^(Characters|Items|Triggers)/.*\\.lsf$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); foreach (var levelFile in levelFiles) { var fileInfo = new FilesystemFileInfo { FilesystemPath = levelsPath + "\\" + levelFile, Name = levelFile }; AddLevelObjectsToMod(modName, levelFile, fileInfo); } }
private static void AddFilesToPackage(Package package, string path, string dataRootPath, string outputPath, List <string> ignoredFiles) { if (!path.EndsWith(Path.DirectorySeparatorChar.ToString())) { path += Path.DirectorySeparatorChar; } var files = Directory.EnumerateFiles(path, DirectoryEnumerationOptions.Recursive | DirectoryEnumerationOptions.LargeCache, new DirectoryEnumerationFilters() { InclusionFilter = (f) => { return(!ignoredFiles.Any(x => IgnoreFile(f.FullPath, x))); } }).ToDictionary(k => k.Replace(dataRootPath, String.Empty), v => v); foreach (KeyValuePair <string, string> file in files) { DivinityApp.Log("Creating FilesystemFileInfo "); FilesystemFileInfo fileInfo = FilesystemFileInfo.CreateFromEntry(file.Value, file.Key); package.Files.Add(fileInfo); } }
private void DiscoverModGlobals(string modName, string modPath) { var globalsPath = modPath + @"\Globals"; if (!Directory.Exists(globalsPath)) { return; } List <string> globalFiles = new List <string>(); EnumerateFiles(globalFiles, globalsPath, globalsPath, "*.lsf"); foreach (var globalFile in globalFiles) { var fileInfo = new FilesystemFileInfo { FilesystemPath = globalsPath + "\\" + globalFile, Name = globalFile }; AddGlobalsToMod(modName, globalFile, fileInfo); } }
private void DiscoverModGoals(string modName, string modPath) { var goalPath = modPath + @"\Story\RawFiles\Goals"; if (!Directory.Exists(goalPath)) { return; } List <string> goalFiles = new List <string>(); EnumerateFiles(goalFiles, goalPath, goalPath, "*.txt"); foreach (var goalFile in goalFiles) { var fileInfo = new FilesystemFileInfo { FilesystemPath = goalPath + "\\" + goalFile, Name = goalFile }; AddScriptToMod(modName, goalFile, fileInfo); } }