public override async ValueTask <Directive?> Run(RawSourceFile source) { if (!_isGenericGame) { return(null); } if (_game == null) { return(null); } if (!_regex.IsMatch((string)source.Path)) { return(null); } try { var lines = await source.AbsolutePath.ReadAllLinesAsync(); var sID = lines.FirstOrDefault(l => l.StartsWith("itemID="))?.Replace("itemID=", ""); if (string.IsNullOrEmpty(sID)) { Utils.Error($"Found no itemID= in file {source.AbsolutePath}!"); return(null); } if (!int.TryParse(sID, out var id)) { Utils.Error($"Unable to parse int {sID} in {source.AbsolutePath}"); return(null); } //Get-ChildItem -Name -Directory | ForEach-Object -Process {Out-File -FilePath .\steamWorkshopItem_$_.meta -InputObject "itemID=$($_)" -Encoding utf8} if (id == 0) { return(null); } SteamWorkshopItem?item = _game.WorkshopItems.FirstOrDefault(x => x.ItemID == id); if (item == null) { Utils.Error($"Unable to find workshop item with ID {id} in loaded workshop item list!"); return(null); } var fromSteam = source.EvolveTo <SteamMeta>(); fromSteam.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath); fromSteam.ItemID = item.ItemID; fromSteam.Size = item.Size; return(fromSteam); } catch (Exception e) { Utils.Error(e, $"Exception while trying to evolve source to FromSteam"); return(null); } }
private Directive RemapFile(RawSourceFile source) { var data = File.ReadAllText(source.AbsolutePath); var originalData = data; data = data.Replace(_compiler.GamePath, Consts.GAME_PATH_MAGIC_BACK); data = data.Replace(_compiler.GamePath.Replace("\\", "\\\\"), Consts.GAME_PATH_MAGIC_DOUBLE_BACK); data = data.Replace(_compiler.GamePath.Replace("\\", "/"), Consts.GAME_PATH_MAGIC_FORWARD); data = data.Replace(_compiler.MO2Folder, Consts.MO2_PATH_MAGIC_BACK); data = data.Replace(_compiler.MO2Folder.Replace("\\", "\\\\"), Consts.MO2_PATH_MAGIC_DOUBLE_BACK); data = data.Replace(_compiler.MO2Folder.Replace("\\", "/"), Consts.MO2_PATH_MAGIC_FORWARD); data = data.Replace(_compiler.MO2DownloadsFolder, Consts.DOWNLOAD_PATH_MAGIC_BACK); data = data.Replace(_compiler.MO2DownloadsFolder.Replace("\\", "\\\\"), Consts.DOWNLOAD_PATH_MAGIC_DOUBLE_BACK); data = data.Replace(_compiler.MO2DownloadsFolder.Replace("\\", "/"), Consts.DOWNLOAD_PATH_MAGIC_FORWARD); if (data == originalData) { return(null); } var result = source.EvolveTo <RemappedInlineFile>(); result.SourceDataID = _compiler.IncludeFile(Encoding.UTF8.GetBytes(data)); return(result); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { var files = new HashSet <AbsolutePath> { _compiler.ModListImage }; if (!files.Any(f => source.AbsolutePath.Equals(f))) { return(null); } if (!source.AbsolutePath.Exists) { return(null); } var isBanner = source.AbsolutePath == _compiler.ModListImage; //var isReadme = source.AbsolutePath == ModListReadme; var result = source.EvolveTo <PropertyFile>(); result.SourceDataID = await _compiler.IncludeFile(await source.AbsolutePath.ReadAllBytesAsync()); if (isBanner) { result.Type = PropertyType.Banner; _compiler.ModListImage = result.SourceDataID.RelativeTo(_compiler.ModListOutputFolder); } return(result); }
public override Directive Run(RawSourceFile source) { var files = new HashSet <string> { _compiler.ModListImage, _compiler.ModListReadme }; if (!files.Any(f => source.AbsolutePath.Equals(f))) { return(null); } if (!File.Exists(source.AbsolutePath)) { return(null); } var isBanner = source.AbsolutePath == _compiler.ModListImage; //var isReadme = source.AbsolutePath == ModListReadme; var result = source.EvolveTo <PropertyFile>(); result.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath)); if (isBanner) { result.Type = PropertyType.Banner; _compiler.ModListImage = result.SourceDataID; } else { result.Type = PropertyType.Readme; _compiler.ModListReadme = result.SourceDataID; } return(result); }
public override async ValueTask <Directive> Run(RawSourceFile source) { var result = source.EvolveTo <NoMatch>(); result.Reason = "No Match in Stack"; return(result); }
public override async ValueTask <Directive> Run(RawSourceFile source) { var l = new List <string> { "vortex.deployment.msgpack", "vortex.deployment.json" }; if (!l.Any(a => source.Path.Contains(a))) { return(null); } var inline = source.EvolveTo <InlineFile>(); inline.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath)); if (!source.Path.Contains("vortex.deployment.json")) { return(inline); } var path = source.Path; if (!path.StartsWith(Consts.GameFolderFilesDir)) { return(inline); } path = path.Substring(Consts.GameFolderFilesDir.Length + 1); path = $"{Consts.ManualGameFilesDir}\\{path}"; inline.To = path; return(inline); }
public override async ValueTask <Directive> Run(RawSourceFile source) { var filename = Path.GetFileName(source.Path); var gameFile = Path.Combine(_mo2Compiler.GamePath, "Data", filename); if (!Consts.GameESMs.Contains(filename) || !source.Path.StartsWith("mods\\") || !File.Exists(gameFile)) { return(null); } Utils.Log( $"An ESM named {filename} was found in a mod that shares a name with one of the core game ESMs, it is assumed this is a cleaned ESM and it will be binary patched"); var result = source.EvolveTo <CleanedESM>(); result.SourceESMHash = _compiler.VFS.Index.ByRootPath[gameFile].Hash; Utils.Status($"Generating patch of {filename}"); await using (var ms = new MemoryStream()) { await Utils.CreatePatch(File.ReadAllBytes(gameFile), File.ReadAllBytes(source.AbsolutePath), ms); var data = ms.ToArray(); result.SourceDataID = _compiler.IncludeFile(data); Utils.Log($"Generated a {data.Length} byte patch for {filename}"); } return(result); }
public static CSharpFile AddOrUpdateProjectItemFile(this Solution solution, RawSourceFile rawSourceFile) { Ensure.ArgumentNotNull(solution, "solution"); try { var project = solution.Projects.FirstOrDefault( p => p.FileName.Equals(rawSourceFile.ProjectFileName)); if (null == project) { _log.ErrorFormat("Failed AddOrUpdateProjectItemFile [{0}] because could not find Project [{1}]", rawSourceFile.FileName, rawSourceFile.ProjectFileName); //TODO: Should this throw an exception instead? return(null); } var csharpFile = new CSharpFile(project, rawSourceFile.FileName, rawSourceFile.FileContents); project.AddOrUpdateCSharpFile(csharpFile); solution.RecreateCompilations(); return(csharpFile); } catch (Exception e) { _log.Error("Exception in AddOrUpdateCodeGeneratorFileSource: " + e.Message, e); throw; } }
public override Directive Run(RawSourceFile source) { var inline = source.EvolveTo <InlineFile>(); inline.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath)); return(inline); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { var inline = source.EvolveTo <InlineFile>(); inline.SourceDataFile = source.File; return(inline); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { if (_includeSaves) { foreach (var folderpath in _profilePaths) { if (!source.AbsolutePath.InFolder(folderpath)) { continue; } var result = source.EvolveTo <InlineFile>(); result.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath); return(result); } } else { if (!_profilePaths.Any(p => source.File.AbsoluteName.InFolder(p))) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = "Ignore Save files"; return(result); } return(null); }
public override async ValueTask <Directive> Run(RawSourceFile source) { var result = source.EvolveTo <NoMatch>(); result.Reason = "No Match in Stack"; Utils.Log($"No match for: {source.Path}"); return(result); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { var inline = source.EvolveTo <InlineFile>(); inline.SourceDataID = await _compiler.IncludeFile(await source.AbsolutePath.ReadAllBytesAsync()); return(inline); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { var inline = source.EvolveTo <InlineFile>(); await using var file = source.File.StagedFile.OpenRead(); inline.SourceDataID = await _compiler.IncludeFile(await file.ReadAllAsync()); return(inline); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { if (!((string)source.Path).StartsWith(_startDir, System.StringComparison.OrdinalIgnoreCase)) { return(null); } var i = source.EvolveTo <IgnoredDirectly>(); i.Reason = "Default game file"; return(i); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { if (!((string)source.Path).EndsWith(_postfix)) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = _reason; return(result); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { if (!_cruftFiles.Any(f => source.Path.StartsWith(f))) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = "Wabbajack Cruft file"; return(result); }
public override Directive Run(RawSourceFile source) { if (!source.Path.StartsWith("mods") || _allEnabledMods.Any(mod => source.Path.StartsWith(mod))) { return(null); } var r = source.EvolveTo <IgnoredDirectly>(); r.Reason = "Disabled Mod"; return(r); }
public override Directive Run(RawSourceFile source) { if (source.Path.StartsWith(_prefix)) { var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = _reason; return(result); } return(null); }
public override Directive Run(RawSourceFile source) { if (!source.Path.StartsWith("mods\\") || !source.Path.EndsWith("\\meta.ini")) { return(null); } var e = source.EvolveTo <InlineFile>(); e.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath)); return(e); }
public override Directive Run(RawSourceFile source) { if (!source.Path.Contains(_pattern)) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = _reason; return(result); }
public override Directive Run(RawSourceFile source) { if (!source.Path.StartsWith(_startDir)) { return(null); } var i = source.EvolveTo <IgnoredDirectly>(); i.Reason = "Default game file"; return(i); }
public override Directive Run(RawSourceFile source) { if (!source.Path.StartsWith(_prefix)) { return(null); } var result = source.EvolveTo <InlineFile>(); result.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath).ToBase64()); return(result); }
public override Directive Run(RawSourceFile source) { if (!source.Path.EndsWith(_postfix)) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = _reason; return(result); }
public override async ValueTask <Directive> Run(RawSourceFile source) { if (!source.Path.StartsWith(Consts.MO2ModFolderName) || _allEnabledMods.Any(mod => source.Path.StartsWith(mod))) { return(null); } var r = source.EvolveTo <IgnoredDirectly>(); r.Reason = "Disabled Mod"; return(r); }
public override async ValueTask <Directive> Run(RawSourceFile source) { if (Path.GetDirectoryName(source.AbsolutePath) != _vortex.DownloadsFolder) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = "Ignored because it is a Vortex file"; return(result); }
public override async ValueTask <Directive> Run(RawSourceFile source) { if (!Consts.ConfigFileExtensions.Contains(Path.GetExtension(source.Path))) { return(null); } var result = source.EvolveTo <InlineFile>(); result.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath)); return(result); }
public override async ValueTask <Directive> Run(RawSourceFile source) { if (!_regex.IsMatch(source.Path)) { return(null); } var result = source.EvolveTo <IgnoredDirectly>(); result.Reason = _reason; return(result); }
public override Directive Run(RawSourceFile source) { if (!_regex.IsMatch(source.Path)) { return(null); } var result = source.EvolveTo <InlineFile>(); result.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath)); return(result); }
public override async ValueTask <Directive?> Run(RawSourceFile source) { if (!source.Path.StartsWith("mods\\") || source.Path.FileName != Consts.MetaIni) { return(null); } var e = source.EvolveTo <InlineFile>(); e.SourceDataID = await _compiler.IncludeFile(await source.AbsolutePath.ReadAllBytesAsync()); return(e); }