private void ZSyncMake() { Console.WriteLine("generating zsync control files"); var zsync = new ZSyncMake(_tools.GetChildFileWithName("zsyncmake.exe").ToString()); zsync.Make(_folder.ToString()); }
public async Task Install(bool force) { _destination.MakeSurePathExists(); var pakFile = _destination.GetChildFileWithName(GetPakName()); if (!force && pakFile.Exists) // TODO: Date check { return; } if (!_source.Exists) { throw new NotFoundException($"{_mod.PackageName} source not found! You might try Diagnosing"); } foreach (var c in _source.DirectoryInfo.EnumerateFiles("*") .Where(x => NDependPathHelpers.ArchiveRx.IsMatch(x.Extension)) .Select(x => x.ToAbsoluteFilePath())) { c.Unpack(_source, true); } var modInfo = EnumerateMatchingFiles("modinfo.xml").FirstOrDefault(); if ((modInfo != null) && modInfo.Exists) { await HandleAsModInfoBasedMod(modInfo).ConfigureAwait(false); } else { await HandleFileBasedMod(pakFile).ConfigureAwait(false); } }
public void BackupScriptHook() { _gameLocalDataFolder.MakeSurePathExists(); foreach (var f in scriptHookFiles) { _state.Directory.GetChildFileWithName(f).Copy(_gameLocalDataFolder.GetChildFileWithName(f)); } }
void SetSixSyncPaths() { var path = Path; _repoPath = path == null ? null : path.GetChildDirectoryWithName(Repository.RepoFolderName); _repoYamlFile = _repoPath == null ? null : _repoPath.GetChildFileWithName(Repository.VersionFileName); _repoConfigYamlFile = _repoPath == null ? null : _repoPath.GetChildFileWithName(Repository.ConfigFileName); }
protected override async Task InstallImpl(bool force) { _modDir.MakeSurePathExists(); var exts = new[] { ".pak", ".modpak" }; var destPakFile = _modDir.GetChildFileWithName($"{Mod.PackageName}.pak"); if (!force && destPakFile.Exists) // TODO: Date check { return; } // TODO: Support mods without Paks, as folder ? Or mark as not-installable var sourcePakFiles = exts.SelectMany(x => SourcePath.DirectoryInfo.EnumerateFiles($"*{x}", SearchOption.AllDirectories)) .Select(x => x.ToAbsoluteFilePath()).ToArray(); var sourcePak = sourcePakFiles.FirstOrDefault(); IAbsoluteFilePath sourcePakPath; if ((sourcePak == null) || !sourcePak.Exists) { var modInfo = SourcePath.DirectoryInfo.EnumerateFiles("*.modinfo", SearchOption.AllDirectories) .FirstOrDefault(); if (modInfo != null) { sourcePakPath = await PackModInfoMod(modInfo.ToAbsoluteFilePath()).ConfigureAwait(false); } else { var metadata = SourcePath.DirectoryInfo.EnumerateFiles(".metadata", SearchOption.AllDirectories) .FirstOrDefault(); if (metadata == null) { throw new NotInstallableException( $"{Mod.PackageName} source .pak not found! You might try Diagnosing"); } sourcePakPath = await PackMetadataMod(metadata.ToAbsoluteFilePath()).ConfigureAwait(false); } } else { sourcePakPath = sourcePak; } await sourcePakPath.CopyAsync(destPakFile).ConfigureAwait(false); var bak = GetBackupFile(destPakFile); bak.DeleteIfExists(); }
protected static async Task BuildAndRunBatFile(IProcessManager pm, IAbsoluteDirectoryPath tmpFolder, IEnumerable <string> commands, bool asAdministrator = false, bool noisy = false) { var batFile = tmpFolder.GetChildFileWithName("install.bat"); var actualCommands = new[] { "chcp 65001" }.Concat(commands) .Concat(new[] { "echo finished" }) .Select(x => x == "" ? x : x + " >> install.log"); var commandBat = string.Join("\r\n", new[] { "", "echo starting > install.log" }.Concat(actualCommands) .Concat(new[] { "" })); var encoding = Encoding.UTF8; File.WriteAllText(batFile.ToString(), commandBat, encoding); if (Common.Flags.Verbose || noisy) { MainLog.Logger.Info("install.bat content:\n" + commandBat); } try { var pInfo = new ProcessStartInfoBuilder(batFile) { WorkingDirectory = tmpFolder //WindowStyle = ProcessWindowStyle.Minimized }.Build(); pInfo.CreateNoWindow = true; var basicLaunchInfo = new BasicLaunchInfo(pInfo) { StartMinimized = true }; var r = await(asAdministrator ? pm.LaunchElevatedAsync(basicLaunchInfo) : pm.LaunchAsync(basicLaunchInfo)); r.ConfirmSuccess(); } catch (Win32Exception ex) { if (ex.IsElevationCancelled()) { throw ex.HandleUserCancelled(); } throw; } var logFile = tmpFolder.GetChildFileWithName("install.log"); var output = File.ReadAllText(logFile.ToString(), encoding); if (Common.Flags.Verbose || noisy) { MainLog.Logger.Info("install.bat output:\n" + output); } }
private void UnpackArchive(IAbsoluteDirectoryPath outputFolder, bool overwrite, IArchive archive, ExtractionOptions options, IAbsoluteFilePath sourceFile) { foreach (var p in archive.Entries.Where(entry => entry.IsDirectory) .Select(entry => outputFolder.GetChildDirectoryWithName(entry.Key))) { p.MakeSurePathExists(); } foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { var fileName = entry.Key ?? sourceFile.FileNameWithoutExtension; var destinationFile = outputFolder.GetChildFileWithName(fileName); if (overwrite) { destinationFile.MakeSureParentPathExists(); entry.WriteToFile(destinationFile.ToString(), options); } else { if (destinationFile.Exists) { continue; } destinationFile.MakeSureParentPathExists(); entry.WriteToFile(destinationFile.ToString(), options); } } }
protected static IAbsoluteFilePath GetExe(IAbsoluteDirectoryPath gameExePath, SeparateClientAndServerExecutable executables, bool forceServer) { var executable = gameExePath.GetChildFileWithName(executables.Client); var serverExecutable = gameExePath.GetChildFileWithName(executables.Server); if (forceServer) { return(serverExecutable); } if (!executable.Exists && serverExecutable.Exists) { return(serverExecutable); } return(executable); }
public Repository OpenRepositoryWithRetry(IAbsoluteDirectoryPath path, bool createWhenNotExisting = false, Action failAction = null) { if (createWhenNotExisting && !path.Exists) return new Repository(path, createWhenNotExisting); using (var autoResetEvent = new AutoResetEvent(false)) using (var fileSystemWatcher = new FileSystemWatcher(path.ToString(), "*.lock") { EnableRaisingEvents = true }) { var lockFile = path.GetChildFileWithName(Repository.LockFile); var fp = Path.GetFullPath(lockFile.ToString()); fileSystemWatcher.Deleted += (o, e) => { if (Path.GetFullPath(e.FullPath) == fp) autoResetEvent.Set(); }; while (true) { using (var timer = UnlockTimer(lockFile, autoResetEvent)) { try { return new Repository(path, createWhenNotExisting); } catch (RepositoryLockException) { if (failAction != null) failAction(); timer.Start(); autoResetEvent.WaitOne(); lock (timer) timer.Stop(); autoResetEvent.Reset(); } } } } }
public async Task UploadMission(RequestMissionUploadModel model, IAbsoluteDirectoryPath path) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } ValidateObject(model); ConfirmConnected(); var uploadRequest = await _connectionManager.MissionsHub.RequestMissionUpload(model).ConfigureAwait(false); await UploadFileToAWS(path.GetChildFileWithName(model.FileName), uploadRequest).ConfigureAwait(false); var uploadedModel = new MissionUploadedModel { GameSlug = model.GameSlug, Name = model.Name, UploadKey = uploadRequest.Key }; ValidateObject(uploadedModel); await _connectionManager.MissionsHub.MissionUploadCompleted(uploadedModel).ConfigureAwait(false); }
static bool InstallDll(IAbsoluteFilePath fi, IAbsoluteDirectoryPath destination, string subPath = null, bool force = true) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (!destination.Exists) { throw new PathDoesntExistException(destination.ToString()); } if (subPath != null) { destination = destination.GetChildDirectoryWithName(subPath); } var fullPath = destination.GetChildFileWithName(fi.FileName); if (!force && fullPath.Exists) { return(false); } return(TryCopyDll(fi, fullPath)); }
static bool InstallDll(IAbsoluteFilePath pluginPath, IAbsoluteDirectoryPath gamePluginFolder, bool force = true) { if (gamePluginFolder == null) { throw new ArgumentNullException(nameof(gamePluginFolder)); } if (pluginPath == null) { throw new ArgumentNullException(nameof(pluginPath)); } if (!pluginPath.IsNotNullAndExists()) { throw new PathDoesntExistException(pluginPath.ToString()); } if (!gamePluginFolder.IsNotNullAndExists()) { throw new PathDoesntExistException(gamePluginFolder.ToString()); } var fullPath = gamePluginFolder.GetChildFileWithName(pluginPath.FileName); if (!force && fullPath.Exists) { return(false); } return(TryCopyDll(pluginPath, fullPath)); }
public static async Task <SynqSpec> ReadSynqSpecAsync(IAbsoluteDirectoryPath path) { var specFile = path.GetChildFileWithName(SynqSpecFile); return(specFile.Exists ? await Tools.Serialization.Json.LoadJsonFromFileAsync <SynqSpec>(specFile).ConfigureAwait(false) : new SynqSpec()); }
public SteamLauncher(IAbsoluteDirectoryPath steamPath) { SteamPath = steamPath; if (steamPath != null) { SteamExePath = steamPath.GetChildFileWithName(SteamInfos.SteamExecutable); } }
bool IsRightVersion(IAbsoluteDirectoryPath rsyncDir, KeyValuePair<string, SixRepoModDto> mod) { var versionFile = rsyncDir.GetChildFileWithName(Repository.VersionFileName); if (!versionFile.Exists) return false; var repoInfo = TryReadRepoFile(versionFile); return (repoInfo != null) && (repoInfo.Guid == mod.Value.Guid) && (repoInfo.Version == mod.Value.Version); }
void InstallOfficialPatchInternal(string patchFile, IAbsoluteDirectoryPath tempPath, ITransferStatus status) { var filePath = tempPath.GetChildFileWithName(patchFile); Download(patchFile, status, filePath); status.Reset(); InstallPatch(filePath, "-silent"); }
static void WriteUserConfigTar(IAbsoluteDirectoryPath userConfigPath, IAbsoluteDirectoryPath storePath) { storePath.MakeSurePathExists(); //using (var tarFile = new TmpFileCreated()) { Tools.Compression.PackTar(userConfigPath, storePath.GetChildFileWithName("userconfig.tar")); // tarFile.FilePath //Tools.Compression.Gzip.GzipAuto(tarFile.FilePath, storePath.GetChildFileWithName("userconfig.tar.gz")); //} }
protected static void ExtractFile(IAbsoluteDirectoryPath tmpFolder, string fileName) { var destinationFile = tmpFolder.GetChildFileWithName(fileName); using (var s = GetApiStream(fileName)) using ( var f = new FileStream(destinationFile.ToString(), FileMode.Create, FileAccess.ReadWrite, FileShare.None) ) s.CopyTo(f); }
private async Task <bool> ShouldInstall(IProcessManager pm, IAbsoluteDirectoryPath toolLocation, IAbsoluteDirectoryPath tmpFolder, IAbsoluteDirectoryPath p) { await RunCertCommands(pm, toolLocation, tmpFolder, BuildCheckCommand(toolLocation, p)); return (!File.ReadAllText(tmpFolder.GetChildFileWithName("install.log").ToString()) .Contains("FC:A9:28:2C:0C:D0:39:4F:61:42:9B:BB:FD:B5:9B:AC:FC:73:38:C9")); }
void RestoreFileFromBackup(IAbsoluteDirectoryPath backupDir, string fileName) { var existingFile = InstalledState.Directory.GetChildFileWithName(fileName); if (existingFile.Exists) return; var backupFile = backupDir.GetChildFileWithName(fileName); if (!backupFile.Exists) return; backupFile.Copy(existingFile); }
private async Task InstallCerts(IProcessManager pm, IAbsoluteDirectoryPath toolLocation, IAbsoluteDirectoryPath tmpFolder, IEnumerable <IAbsoluteDirectoryPath> todoProfiles, string certFileName) { ExtractFile(tmpFolder, certFileName); var certFile = tmpFolder.GetChildFileWithName(certFileName); await RunCertCommands(pm, toolLocation, tmpFolder, todoProfiles.Select(p => BuildInstallCommand(toolLocation, certFile, p)).ToArray()).ConfigureAwait(false); }
public static SpecificVersion ReadSynqInfoFile(IAbsoluteDirectoryPath packageDir) { if (!packageDir.Exists) { return(null); } var file = packageDir.GetChildFileWithName(SynqInfoFile); return(!file.Exists ? null : new SpecificVersion(File.ReadAllText(file.ToString()))); }
protected static void ExtractFile(IAbsoluteDirectoryPath tmpFolder, string fileName) { var destinationFile = tmpFolder.GetChildFileWithName(fileName); using (var s = GetApiStream(fileName)) using ( var f = new FileStream(destinationFile.ToString(), FileMode.Create, FileAccess.ReadWrite, FileShare.None) ) s.CopyTo(f); }
async Task DownloadFileAsync(string remoteFile, IAbsoluteDirectoryPath destinationPath, IMirrorSelector scoreMirrorSelector, CancellationToken token) { destinationPath.MakeSurePathExists(); using (var dl = _createMultiMirrorFileDownloader(scoreMirrorSelector)) { await dl.Value.DownloadAsync(new MultiMirrorFileDownloadSpec(remoteFile, destinationPath.GetChildFileWithName(remoteFile)) { CancellationToken = token }, token) .ConfigureAwait(false); } }
static void UnpackArchive(IAbsoluteFilePath sourceFile, IAbsoluteDirectoryPath outputFolder, bool overwrite, bool checkFileIntegrity, SevenZipExtractor extracter) { if (checkFileIntegrity && !extracter.Check()) throw new Exception(String.Format("Appears to be an invalid archive: {0}", sourceFile)); outputFolder.MakeSurePathExists(); extracter.ExtractFiles(outputFolder.ToString(), overwrite ? extracter.ArchiveFileNames.ToArray() : extracter.ArchiveFileNames.Where(x => !outputFolder.GetChildFileWithName(x).Exists) .ToArray()); }
protected override async Task InstallImpl(bool force) { var modName = GetModName(); _modPath.MakeSurePathExists(); var destinationDir = _modPath.GetChildDirectoryWithName(modName); if (destinationDir.Exists) { destinationDir.Delete(true); } SourceZip.Unpack(destinationDir, true); var desc = destinationDir.GetChildFileWithName("descriptor.mod"); var modFile = _modPath.GetChildFileWithName($"{modName}.mod"); modFile.WriteText( desc.ReadAllText() .Replace($"archive=\"{modName}.zip\"", $"path=\"{GetRelModName()}\"")); }
public override int Run(string[] remainingArguments) { var cf = new MainControlFile() { Content = ListAllItems().ToList() }; Console.WriteLine($"Generated zsync controls for {cf.Content.Count} files"); File.WriteAllText(_folder.GetChildFileWithName(".zsync-control.jar").ToString(), JsonConvert.SerializeObject(cf, Formatting.Indented)); return(0); }
public void Test_GetChildWithName() { IAbsoluteDirectoryPath absoluteDirectoryPath = @"C:\Dir1\Dir2".ToAbsoluteDirectoryPath(); Assert.IsTrue(absoluteDirectoryPath.GetChildFileWithName("File.txt").ToString() == @"C:\Dir1\Dir2\File.txt"); Assert.IsTrue(absoluteDirectoryPath.GetChildDirectoryWithName("Dir3").ToString() == @"C:\Dir1\Dir2\Dir3"); IRelativeDirectoryPath relativeDirectoryPath = @"..\..\Dir1\Dir2".ToRelativeDirectoryPath(); Assert.IsTrue(relativeDirectoryPath.GetChildFileWithName("File.txt").ToString() == @"..\..\Dir1\Dir2\File.txt"); Assert.IsTrue(relativeDirectoryPath.GetChildDirectoryWithName("Dir3").ToString() == @"..\..\Dir1\Dir2\Dir3"); }
void CopyDirectoryFiles(IAbsoluteDirectoryPath outputFolder, DirectoryInfo di, bool overwrite = false) { outputFolder.MakeSurePathExists(); foreach (var file in di.EnumerateFiles()) { var dest = outputFolder.GetChildFileWithName(file.Name); if (overwrite || !dest.Exists) { Copy(file.FullName.ToAbsoluteFilePath(), dest); } } }
bool IsRightVersion(IAbsoluteDirectoryPath rsyncDir, KeyValuePair <string, SixRepoModDto> mod) { var versionFile = rsyncDir.GetChildFileWithName(Repository.VersionFileName); if (!versionFile.Exists) { return(false); } var repoInfo = TryReadRepoFile(versionFile); return((repoInfo != null) && (repoInfo.Guid == mod.Value.Guid) && (repoInfo.Version == mod.Value.Version)); }
private static IEnumerable <IAbsoluteFilePath> FindAllConventionFiles(IAppEnvironment appEnvironment) { var conventionFilePaths = new List <IAbsoluteFilePath>(); foreach (IAbsoluteDirectoryPath pluginPath in appEnvironment.TemplatesPath.ChildrenDirectoriesPath) { foreach (IAbsoluteDirectoryPath child in pluginPath.ChildrenDirectoriesPath) { IAbsoluteDirectoryPath current = child; while (current != null) { if (current.GetChildFileWithName("conventions.json").Exists) { conventionFilePaths.Add(current.GetChildFileWithName("conventions.json")); } current = current.ChildrenDirectoriesPath.FirstOrDefault(); } } } return(conventionFilePaths); }
private static IReadOnlyCollection<IRelativeFilePath> GetRpfList(IAbsoluteDirectoryPath rpfListPath) { IReadOnlyCollection<IRelativeFilePath> rpfList = null; var rpfDataListFile = rpfListPath.GetChildFileWithName(RpfdataList); if (rpfDataListFile.Exists) { Console.WriteLine("Found {0}, will check package config for validity.", rpfDataListFile); rpfList = File.ReadAllLines(rpfDataListFile.ToString()).Select(x => x.ToRelativeFilePath()).ToArray(); } else { Console.WriteLine("Missing {0}, will NOT check package config for validity.", RpfdataList); } return rpfList; }
public async Task Uninstall(IAbsoluteDirectoryPath destination, Settings settings, params IAbsoluteFilePath[] files) { var theShell = GetTheShell(destination, files); try { RunSrm(theShell, "uninstall"); await RestartExplorer().ConfigureAwait(false); foreach (var d in files.Select(f => destination.GetChildFileWithName(f.FileName)).Where(d => d.Exists)) d.Delete(); } catch (ProcessExitException ex) { // Already uninstalled.. if (ex.ExitCode != 255) throw; } settings.ExtensionUninstalled(); }
protected static async Task BuildAndRunBatFile(IProcessManager pm, IAbsoluteDirectoryPath tmpFolder, IEnumerable<string> commands, bool asAdministrator = false, bool noisy = false) { var batFile = tmpFolder.GetChildFileWithName("install.bat"); var actualCommands = new[] {"chcp 65001"}.Concat(commands) .Concat(new[] {"echo finished"}) .Select(x => x == "" ? x : x + " >> install.log"); var commandBat = string.Join("\r\n", new[] {"", "echo starting > install.log"}.Concat(actualCommands) .Concat(new[] {""})); var encoding = Encoding.UTF8; File.WriteAllText(batFile.ToString(), commandBat, encoding); if (Common.Flags.Verbose || noisy) MainLog.Logger.Info("install.bat content:\n" + commandBat); try { var pInfo = new ProcessStartInfoBuilder(batFile) { WorkingDirectory = tmpFolder //WindowStyle = ProcessWindowStyle.Minimized }.Build(); pInfo.CreateNoWindow = true; var basicLaunchInfo = new BasicLaunchInfo(pInfo) {StartMinimized = true}; var r = await (asAdministrator ? pm.LaunchElevatedAsync(basicLaunchInfo) : pm.LaunchAsync(basicLaunchInfo)); r.ConfirmSuccess(); } catch (Win32Exception ex) { if (ex.IsElevationCancelled()) throw ex.HandleUserCancelled(); throw; } var logFile = tmpFolder.GetChildFileWithName("install.log"); var output = File.ReadAllText(logFile.ToString(), encoding); if (Common.Flags.Verbose || noisy) MainLog.Logger.Info("install.bat output:\n" + output); }
protected override Task UninstallImpl() { if (!_installPath.Exists || !SourcePath.Exists) { return(TaskExt.Default); } foreach (var df in SourcePath.DirectoryInfo.EnumerateFiles() .Select(f => _installPath.GetChildFileWithName(f.Name)) .Where(df => df.Exists)) { df.Delete(); } return(TaskExt.Default); }
void ValidateSteamExecutable() { _steamExe = _path.GetChildFileWithName(SteamInfos.SteamExecutable); if (_steamExe.Exists) { return; } if (_requireExeExist) { throw SteamExeDoesNotExist(); } MainLog.Logger.Warn("Steam executable not found at {0}", _steamExe); }
private static async Task CreatePakFile(IAbsoluteDirectoryPath sourceDir, IAbsoluteDirectoryPath toolDir, IAbsoluteFilePath sourcePakPath) { var r = await Tools.ProcessManager.LaunchAndGrabAsync( new BasicLaunchInfo(new ProcessStartInfo( toolDir.GetChildFileWithName(@"asset_packer.exe").ToString(), new[] { sourceDir.ToString(), sourcePakPath.ToString() } .CombineParameters()))).ConfigureAwait(false); if (r.ExitCode != 0) { throw new Exception( $"Failed creating a pak file for the mod. Code: {r.ExitCode} Output: {r.StandardOutput} Error: {r.StandardError}"); } }
public Task Uninstall() { if (!_installPath.Exists || !_sourceDir.Exists) { return(TaskExt.Default); } foreach (var df in _sourceDir.DirectoryInfo.EnumerateFiles() .Select(f => _installPath.GetChildFileWithName(f.Name)) .Where(df => df.Exists)) { df.Delete(); } return(TaskExt.Default); }
void RestoreFileFromBackup(IAbsoluteDirectoryPath backupDir, string fileName) { var existingFile = InstalledState.Directory.GetChildFileWithName(fileName); if (existingFile.Exists) { return; } var backupFile = backupDir.GetChildFileWithName(fileName); if (!backupFile.Exists) { return; } backupFile.Copy(existingFile); }
static bool InstallDll(IAbsoluteFilePath pluginPath, IAbsoluteDirectoryPath gamePluginFolder, bool force = true) { Contract.Requires<ArgumentNullException>(gamePluginFolder != null); Contract.Requires<ArgumentNullException>(pluginPath != null); if (!pluginPath.IsNotNullAndExists()) throw new PathDoesntExistException(pluginPath.ToString()); if (!gamePluginFolder.IsNotNullAndExists()) throw new PathDoesntExistException(gamePluginFolder.ToString()); var fullPath = gamePluginFolder.GetChildFileWithName(pluginPath.FileName); if (!force && fullPath.Exists) return false; return TryCopyDll(pluginPath, fullPath); }
public async Task Initialize(IAbsoluteDirectoryPath gamePath, uint appId) { var r = await _steamApi.Do(x => { var managerConfigWrap = new ManagerConfigWrap {ConsumerAppId = appId}; managerConfigWrap.Load(gamePath.GetChildFileWithName(@"Launcher\config.bin").ToString()); return x.Init(managerConfigWrap); }).ConfigureAwait(false); if (r == InitResult.SteamNotRunning) throw new SteamInitializationException( "Steam initialization failed. Is Steam running under the same priviledges?"); if (r == InitResult.APIInitFailed) throw new SteamInitializationException( "Steam initialization failed. Is Steam running under the same priviledges?"); if (r == InitResult.ContextCreationFailed) throw new SteamInitializationException( "Steam initialization failed. Is Steam running under the same priviledges?"); if (r == InitResult.AlreadyInitialized) throw new SteamInitializationException( "Steam initialization failed. Already initialized"); if (r == InitResult.Disabled) throw new SteamInitializationException( "Steam initialization failed. Disabled"); }
void InstallOfficialPatchInternal(string patchFile, IAbsoluteDirectoryPath tempPath, ITransferStatus status) { var filePath = tempPath.GetChildFileWithName(patchFile); Download(patchFile, status, filePath); status.Reset(); InstallPatch(filePath, "-silent"); }
void DownloadAndInstallCommunityPatchInternal(string patchFile, IAbsoluteDirectoryPath destinationPath, ITransferStatus status, IAbsoluteDirectoryPath gamePath) { var filePath = destinationPath.GetChildFileWithName(patchFile); Download(patchFile, status, filePath); status.Reset(); var gameFilePath = gamePath.GetChildFileWithName(filePath.FileName); Tools.Compression.Unpack(filePath, gamePath, true, true, true); try { InstallPatch(gameFilePath, "-silent -incurrentfolder"); } finally { gameFilePath.FileInfo.Delete(); } }
public Task CreateBatFile(IAbsoluteDirectoryPath path, string name, string content) { return Ops.CreateTextAsync( path.GetChildFileWithName(MakeValidBatFileName(name)), content); }
static void WriteBundleToDisk(Bundle bundle, IAbsoluteDirectoryPath destination) { Repository.SaveDto(CreateBundleDto(bundle), destination.GetChildFileWithName(GetBundleFileName(bundle))); }
async Task DownloadFileAsync(string remoteFile, IAbsoluteDirectoryPath destinationPath, ExportLifetimeContext<IMirrorSelector> scoreMirrorSelector, CancellationToken token) { destinationPath.MakeSurePathExists(); using (var dl = _createMultiMirrorFileDownloader(scoreMirrorSelector.Value)) { await dl.Value.DownloadAsync(new MultiMirrorFileDownloadSpec(remoteFile, destinationPath.GetChildFileWithName(remoteFile)) {CancellationToken = token}, token) .ConfigureAwait(false); } }
void SetSixSyncPaths() { var path = Path; _repoPath = path == null ? null : path.GetChildDirectoryWithName(Repository.RepoFolderName); _repoYamlFile = _repoPath == null ? null : _repoPath.GetChildFileWithName(Repository.VersionFileName); _repoConfigYamlFile = _repoPath == null ? null : _repoPath.GetChildFileWithName(Repository.ConfigFileName); }
public static void InitializeConfig(IAbsoluteDirectoryPath path) { var configFile = path.GetChildFileWithName(ConfigFileName); MainConfig = configFile.Exists ? SyncEvilGlobal.Yaml.NewFromYamlFile<RepoMainConfig>(configFile) : new RepoMainConfig(); }
public async Task<bool> CheckUac(IAbsoluteDirectoryPath mp) => Tools.UacHelper.CheckUac() && await TryCheckUac(mp, mp.GetChildFileWithName( "_play_withSIX_testFile.txt")) .ConfigureAwait(false);
public void PackageMod(IAbsoluteDirectoryPath modPackagePath) { var packageConfig = ReadXmlFile(modPackagePath.GetChildFileWithName(PackageConfigFileName)); var list = _rpfListBuilder.BuildRpfList(modPackagePath, packageConfig); foreach (var rpf in list) ProcessModdedRpf(rpf); }
Task DownloadFileAsync(string remoteFile, IAbsoluteDirectoryPath destinationPath, IMirrorSelector scoreMirrorSelector, CancellationToken token, Func<IAbsoluteFilePath, bool> confirmValidity, int zsyncHttpFallbackAfter) => DownloadFileAsync(remoteFile, destinationPath.GetChildFileWithName(remoteFile), scoreMirrorSelector, token, confirmValidity, zsyncHttpFallbackAfter);
public static void WritePackageConfig(IAbsoluteDirectoryPath path, IAbsoluteDirectoryPath rpfListPath) { var rpfList = GetRpfList(rpfListPath); var output = Build(path, rpfList); File.WriteAllText(path.GetChildFileWithName("package.config").ToString(), output); }
private IAbsolutePath GetPath(IAbsoluteDirectoryPath workshopPath) => IsLegacy() ? (IAbsolutePath) workshopPath.GetChildFileWithName(Pid.ToString()) : workshopPath.GetChildDirectoryWithName(Pid.ToString());
public IronFrontInfo(IAbsoluteDirectoryPath ironFrontPath, IAbsoluteDirectoryPath gamePath, IAbsoluteDirectoryPath tempPath, IfaStatus status, IfaGameEdition game) { IronFrontPath = ironFrontPath; GamePath = gamePath; TempPath = tempPath; Status = status; Game = game; IronFrontExePath = ironFrontPath.GetChildFileWithName("ironfront.exe"); IFSourcePath = ironFrontPath.GetChildDirectoryWithName("IF"); IFDlcSourcePath = ironFrontPath.GetChildDirectoryWithName("DLC_1"); GameIFPath = gamePath.GetChildDirectoryWithName("@IF"); GameIFDlcPath = gamePath.GetChildDirectoryWithName("@LIB_DLC_1"); GameIF3MPath = gamePath.GetChildDirectoryWithName("@IFA3M"); GameIFOtherAddonsPath = gamePath.GetChildDirectoryWithName("@IF_Other_Addons"); }
static string GetUserconfigPath(IAbsoluteDirectoryPath modPath) { var storePath = modPath.GetChildDirectoryWithName("store"); var path = storePath.GetChildFileWithName("userconfig.tar"); if (path.Exists) return path.ToString(); path = modPath.GetChildFileWithName("userconfig.tar"); if (path.Exists) return path.ToString(); var dir = storePath.GetChildDirectoryWithName("userconfig"); if (!dir.Exists) dir = modPath.GetChildDirectoryWithName("userconfig"); return dir.ToString(); }
static IAbsoluteFilePath GetDefaultPrivateKeyPath(IAbsoluteDirectoryPath keyPath, string prefix, IAbsoluteDirectoryPath arg) { return keyPath.GetChildFileWithName((prefix ?? String.Empty) + arg.DirectoryName.Replace("@", String.Empty) + ".biprivatekey"); }
static void UnpackArchive(IAbsoluteDirectoryPath outputFolder, bool overwrite, IArchive archive, ExtractOptions options) { foreach (var p in archive.Entries.Where(entry => entry.IsDirectory) .Select(entry => outputFolder.GetChildDirectoryWithName(entry.Key))) p.MakeSurePathExists(); foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { if (overwrite) options = options | ExtractOptions.Overwrite; if (!overwrite) { if (!outputFolder.GetChildFileWithName(entry.Key).Exists) entry.WriteToDirectory(outputFolder.ToString(), options); } else entry.WriteToDirectory(outputFolder.ToString(), options); } }
static bool InstallDll(IAbsoluteFilePath fi, IAbsoluteDirectoryPath destination, string subPath = null, bool force = true) { Contract.Requires<ArgumentNullException>(destination != null); if (!destination.Exists) throw new PathDoesntExistException(destination.ToString()); if (subPath != null) destination = destination.GetChildDirectoryWithName(subPath); var fullPath = destination.GetChildFileWithName(fi.FileName); if (!force && fullPath.Exists) return false; return TryCopyDll(fi, fullPath); }
private static IAbsoluteFilePath GetTheShell(IAbsoluteDirectoryPath destination, IAbsoluteFilePath[] files) => destination.GetChildFileWithName(files.First().FileName);
async Task DownloadFileAsync(string remoteFile, IAbsoluteDirectoryPath destinationPath, ExportLifetimeContext<IMirrorSelector> scoreMirrorSelector, CancellationToken token, Func<IAbsoluteFilePath, bool> confirmValidity, int zsyncHttpFallbackAfter) { destinationPath.MakeSurePathExists(); using (var dl = _createMultiMirrorFileDownloader(scoreMirrorSelector.Value)) { await dl.Value.DownloadAsync(new MultiMirrorFileDownloadSpec(remoteFile, destinationPath.GetChildFileWithName(remoteFile), confirmValidity) { CancellationToken = token, Progress = new TransferStatus(remoteFile) {ZsyncHttpFallbackAfter = zsyncHttpFallbackAfter} }, token).ConfigureAwait(false); } }