void HandleUserconfig(IAbsoluteDirectoryPath dir) { var userConfigPath = dir.GetChildDirectoryWithName("userconfig"); if (!userConfigPath.Exists) return; System.Console.WriteLine("Found userconfig in {0}, processing", dir); HandleUserConfigPath(dir, userConfigPath); }
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)); }
// TODO: localOnly if no update available? - so for local diagnose etc.. public async Task GetMod(string name, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, bool force = false) { var mod = GetMod(name); var folder = destination.GetChildDirectoryWithName(mod.Key); var config = GetOpts(packPath, status, mod); if (!folder.Exists) { var opts = new SyncOptions(); config(opts); await Repository.Factory.Clone(opts.Hosts, folder.ToString(), config) .ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) { return; } var repo = GetRepo(rsyncDir, folder, config); await repo.Update(config).ConfigureAwait(false); }
public string ProcessUserconfig(IAbsoluteDirectoryPath modPath, IAbsoluteDirectoryPath gamePath, string exisitingChecksum, bool force = true) { Contract.Requires<ArgumentNullException>(modPath != null); Contract.Requires<ArgumentNullException>(gamePath != null); var backupAndClean = force; var path = GetUserconfigPath(modPath); if (!File.Exists(path) && !Directory.Exists(path)) return null; this.Logger().Info("Found userconfig to process at " + path); var checksum = GetConfigChecksum(path); if (checksum != exisitingChecksum) backupAndClean = true; var uconfig = gamePath.GetChildDirectoryWithName("userconfig"); var uconfigPath = uconfig.GetChildDirectoryWithName(Mod.GetRepoName(modPath.DirectoryName)); if (backupAndClean) new UserconfigBackupAndClean().ProcessBackupAndCleanInstall(path, gamePath, uconfig, uconfigPath); else new UserconfigUpdater().ProcessMissingFiles(path, gamePath, uconfig, uconfigPath); return checksum; }
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); } } }
private Task CopyToNMSE(IAbsoluteFilePath dll) { var nmseDir = _gameDir.GetChildDirectoryWithName(@"binaries\NMSE"); nmseDir.MakeSurePathExists(); return(dll.CopyAsync(nmseDir)); }
Action <SyncOptions> GetOpts(IAbsoluteDirectoryPath packPath, StatusRepo status, GroupContent mod) => opts => { opts.Hosts = GetHosts(mod).ToList(); //{"required_version", mod.Version}, // TODO //{"required_guid", @group.Id}, // TODO opts.PackPath = packPath.GetChildDirectoryWithName(mod.PackageName); opts.Status = status; };
static void CopyKeyToKeysSubfolder(BiKeyPair key, IAbsoluteDirectoryPath destination) { var keysFolder = destination.GetChildDirectoryWithName("keys"); keysFolder.MakeSurePathExists(); Tools.FileUtil.Ops.CopyWithRetry(key.PublicFile, keysFolder.GetChildFileWithName(key.PublicFile.FileName)); }
Action <SyncOptions> GetOpts(IAbsoluteDirectoryPath packPath, StatusRepo status, KeyValuePair <string, SixRepoModDto> mod) => opt => { opt.Hosts = Hosts.Select(x => new Uri(x, mod.Key)).ToList(); opt.RequiredVersion = mod.Value.Version; opt.RequiredGuid = mod.Value.Guid; opt.PackPath = packPath.GetChildDirectoryWithName(mod.Key); opt.Status = status; };
static void MigrateServerModFolder(IAbsoluteDirectoryPath modFolder, IAbsoluteDirectoryPath modPath) { var folderName = modFolder.DirectoryName; var destination = modPath.GetChildDirectoryWithName(folderName); if (!destination.Exists) Tools.FileUtil.Ops.MoveDirectory(modFolder, destination); else Directory.Delete(modFolder.ToString(), true); }
public bool ExistsAndIsRightVersion(string name, IAbsoluteDirectoryPath destination) { var mod = GetMod(name); var folder = destination.GetChildDirectoryWithName(mod.Key); var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); return(rsyncDir.Exists && IsRightVersion(rsyncDir, mod)); }
protected override void LowInitializer() { //new LowInitializer().GetFolderPath; PathConfiguration.GetFolderPath = folder => _rootPath.GetChildDirectoryWithName("Profile") .GetChildDirectoryWithName(folder.ToString()) .ToString(); }
IAbsoluteDirectoryPath> GetLocalPathData(IAbsoluteDirectoryPath localBasePath) { var dataDir = localBasePath.GetChildDirectoryWithName("Data"); return(Tuple.Create(localBasePath, dataDir.GetChildDirectoryWithName("RoamingData"), dataDir.GetChildDirectoryWithName("LocalData"), dataDir.GetChildDirectoryWithName("Temp"), dataDir.GetChildDirectoryWithName("LocalData SIX Networks").GetChildDirectoryWithName("Shared"))); }
static void TryMoveDir(IAbsoluteDirectoryPath dir, IAbsoluteDirectoryPath newModsPath) { var newPath = newModsPath.GetChildDirectoryWithName(dir.DirectoryName); try { if (newPath.Exists) Directory.Delete(newPath.ToString(), true); } finally { Tools.FileUtil.Ops.MoveDirectory(dir, newPath); } }
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"); }
public static IAbsoluteDirectoryPath GetDirOfUnitTestWithName(string unitTestName) { IAbsoluteDirectoryPath ndependRootPath = ExecutingAssemblyDir.ParentDirectoryPath; IAbsoluteDirectoryPath unitTestPath = ndependRootPath.GetChildDirectoryWithName("NDepend.Test.Dirs"); IAbsoluteDirectoryPath result = unitTestPath.GetChildDirectoryWithName(unitTestName); Debug.Assert(result.Exists); return(result); }
public YomaContent(IAbsoluteDirectoryPath destination, Uri uri, IFileDownloadHelper downloader) { Contract.Requires<ArgumentNullException>(destination != null); _downloader = downloader; Destination = destination; YasDir = Destination.GetChildDirectoryWithName(".yas"); FilesDir = YasDir.GetChildDirectoryWithName("files"); Url = uri; ConfigArchive = YasDir.GetChildFileWithName("config" + ArchiveExtension); TmpPath = YasDir.GetChildDirectoryWithName("tmp"); }
void ProcessPbo(string pboFile, IAbsoluteDirectoryPath tempPath, IAbsoluteDirectoryPath destination) { var d = tempPath.GetChildDirectoryWithName(Path.GetFileNameWithoutExtension(pboFile)); using (new TmpDirectory(d)) { _pboTools.RunExtractPboWithParameters(pboFile.ToAbsoluteFilePath(), tempPath, "RYDPK"); MakePbo(d, destination); } }
LocalContent ScanForAddonFolders(IAbsoluteDirectoryPath path) { var dirs = new[] {"addons", "dta", "common", "dll"}; if (dirs.Any(x => !path.GetChildDirectoryWithName(x).IsEmptySafe())) { return !HasContentAlready(path.DirectoryName) ? new ModLocalContent(path.DirectoryName.ToLower(), _realVirtualityGame.Id, new BasicInstallInfo()) : null; } return null; }
public SteamDirectories(uint appId, string folder, IAbsoluteDirectoryPath steamPath) { Contract.Requires<ArgumentNullException>(appId > 0); Contract.Requires<ArgumentNullException>(folder != null); Contract.Requires<ArgumentNullException>(steamPath != null); // TODO: Take LibraryPath from KV store RootPath = steamPath.GetChildDirectoryWithName("steamapps"); Game = new SteamGameDirectories(folder, RootPath); Workshop = new SteamWorkshopDirectories(appId, RootPath); }
static void InstallFolder(IAbsoluteDirectoryPath di, IAbsoluteDirectoryPath destination, string subPath, bool force) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (!destination.Exists) { throw new PathDoesntExistException(destination.ToString()); } if (subPath != null) { destination = destination.GetChildDirectoryWithName(subPath); } TryCopyFolder(di, destination.GetChildDirectoryWithName(di.DirectoryName), force); }
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()}\"")); }
private async Task <IAbsoluteFilePath> CreatePakFile(IAbsoluteDirectoryPath sourceDir) { var sourcePakPath = Path.GetTempPath().ToAbsoluteDirectoryPath().GetChildFileWithName($"{Mod.PackageName}.pak"); // TODO: Delete after usage var toolDir = _gameDir.GetChildDirectoryWithName("win32"); await CreatePakFile(sourceDir, toolDir, sourcePakPath).ConfigureAwait(false); return(sourcePakPath); }
void HandleUserconfigFiles(IAbsoluteDirectoryPath userConfigPath, IAbsoluteDirectoryPath storePath, IEnumerable<FileInfo> files) { System.Console.WriteLine("File based userconfig"); var subDir = userConfigPath.GetChildDirectoryWithName( userConfigPath.ParentDirectoryPath.DirectoryName.ToLower().Replace("@", "")); subDir.MakeSurePathExists(); foreach (var f in files) f.MoveTo(subDir.GetChildFileWithName(f.Name).ToString()); WriteUserConfigTar(userConfigPath, storePath); userConfigPath.DirectoryInfo.Delete(true); }
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"); }
internal Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection <Uri> hosts, SyncOptions opts) { var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (rsyncFolder.Exists) { throw new Exception("Already appears to be a repository"); } var packFolder = GetPackFolder(opts, rsyncFolder); var configFile = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName); var wdVersionFile = rsyncFolder.GetChildFileWithName(Repository.VersionFileName); var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName); this.Logger().Info("Initializing {0}", folder); rsyncFolder.MakeSurePathExists(); packFolder.MakeSurePathExists(); var config = new RepoConfig { Hosts = hosts.ToList() }; config.PackPath = opts.PackPath?.ToString(); if (opts.Include != null) { config.Include = opts.Include; } if (opts.Exclude != null) { config.Include = opts.Exclude; } var guid = opts.RequiredGuid ?? Guid.NewGuid().ToString(); var packVersion = new RepoVersion { Guid = guid }; if (opts.ArchiveFormat != null) { packVersion.ArchiveFormat = (string)opts.ArchiveFormat; } var wdVersion = SyncEvilGlobal.Yaml.NewFromYaml <RepoVersion>(packVersion.ToYaml()); SyncEvilGlobal.Yaml.ToYamlFile(config, configFile); SyncEvilGlobal.Yaml.ToYamlFile(packVersion, packVersionFile); SyncEvilGlobal.Yaml.ToYamlFile(wdVersion, wdVersionFile); return(TryGetRepository(folder, opts, rsyncFolder)); }
void HandleArma1(ICollection <Game> existingGames, IAbsoluteDirectoryPath aiaModPath) { var a1 = existingGames.FirstOrDefault(g => g.Id == GameGuids.Arma1); if (a1 == null) { return; } existingGames.Remove(a1); AddGameDefaultAndAdditionalModFolders(a1, _additionalAiA); _additionalAiA.Add(aiaModPath.GetChildDirectoryWithName(AllInArmaA1Dummies)); }
public Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection<Uri> hosts, Dictionary<string, object> opts = null) { Contract.Requires<ArgumentNullException>(folder != null); Contract.Requires<ArgumentNullException>(hosts != null); if (opts == null) opts = new Dictionary<string, object>(); var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (rsyncFolder.Exists) throw new Exception("Already appears to be a repository"); var packFolder = Path.Combine(opts.ContainsKey("pack_path") ? ((string) opts["pack_path"]) : rsyncFolder.ToString(), Repository.PackFolderName).ToAbsoluteDirectoryPath(); var configFile = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName); var wdVersionFile = rsyncFolder.GetChildFileWithName(Repository.VersionFileName); var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName); this.Logger().Info("Initializing {0}", folder); rsyncFolder.MakeSurePathExists(); packFolder.MakeSurePathExists(); var config = new RepoConfig {Hosts = hosts.ToArray()}; if (opts.ContainsKey("pack_path")) config.PackPath = (string) opts["pack_path"]; if (opts.ContainsKey("include")) config.Include = (string[]) opts["include"]; if (opts.ContainsKey("exclude")) config.Exclude = (string[]) opts["exclude"]; var guid = opts.ContainsKey("required_guid") ? (string) opts["required_guid"] : Guid.NewGuid().ToString(); var packVersion = new RepoVersion {Guid = guid}; if (opts.ContainsKey("archive_format")) packVersion.ArchiveFormat = (string) opts["archive_format"]; var wdVersion = YamlExtensions.NewFromYaml<RepoVersion>(packVersion.ToYaml()); config.SaveYaml(configFile); packVersion.SaveYaml(packVersionFile); wdVersion.SaveYaml(wdVersionFile); return TryGetRepository(folder.ToString(), opts, rsyncFolder.ToString()); }
LocalContent ScanForAddonFolders(IAbsoluteDirectoryPath path) { var dirs = new[] { "addons", "dta", "common", "dll" }; if (dirs.Any(x => !path.GetChildDirectoryWithName(x).IsEmptySafe())) { return(!HasContentAlready(path.DirectoryName) ? new ModLocalContent(path.DirectoryName.ToLower(), _realVirtualityGame.Id, new BasicInstallInfo()) : null); } return(null); }
static void TryMoveDir(IAbsoluteDirectoryPath dir, IAbsoluteDirectoryPath newModsPath) { var newPath = newModsPath.GetChildDirectoryWithName(dir.DirectoryName); try { if (newPath.Exists) { Directory.Delete(newPath.ToString(), true); } } finally { Tools.FileUtil.Ops.MoveDirectory(dir, newPath); } }
KeyValue ReadSteamConfig() { if ((_steamPath == null) || !_steamPath.Exists) { return(null); } var steamConfigPath = _steamPath.GetChildDirectoryWithName("config").GetChildFileWithName("config.vdf"); return(steamConfigPath.Exists ? KeyValueHelper.LoadFromFile(steamConfigPath) : null); }
static void MigrateServerModFolder(IAbsoluteDirectoryPath modFolder, IAbsoluteDirectoryPath modPath) { var folderName = modFolder.DirectoryName; var destination = modPath.GetChildDirectoryWithName(folderName); if (!destination.Exists) { Tools.FileUtil.Ops.MoveDirectory(modFolder, destination); } else { Directory.Delete(modFolder.ToString(), true); } }
public IAbsoluteDirectoryPath GetRepoPath(string repoDirectory, IAbsoluteDirectoryPath directory, bool local = false) { if (string.IsNullOrWhiteSpace(repoDirectory)) { repoDirectory = directory.GetChildDirectoryWithName(Repository.DefaultRepoRootDirectory).ToString(); if (!Directory.Exists(repoDirectory)) { var dir = Tools.FileUtil.FindPathInParents(directory.ToString(), Repository.DefaultRepoRootDirectory); if (dir != null && Directory.Exists(dir)) repoDirectory = dir; else if (local) repoDirectory = directory.ToString(); } } return Legacy.SixSync.Repository.RepoTools.GetRootedPath(repoDirectory); }
public async Task GetMod(GroupContent mod, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, IAuthProvider provider, bool force = false) { var folder = destination.GetChildDirectoryWithName(mod.PackageName); if (!folder.Exists) { await InstallNew(mod, provider, GetOpts(packPath, status, mod), folder).ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) return; await UpdateExisting(mod, provider, rsyncDir, folder, GetOpts(packPath, status, mod)).ConfigureAwait(false); }
void ExtractFolder(IAbsoluteDirectoryPath rootPath, IAbsoluteDirectoryPath tempPath, IAbsoluteDirectoryPath destination, IStatus status) { destination = destination.GetChildDirectoryWithName("addons"); destination.MakeSurePathExists(); var files = Directory.GetFiles(Path.Combine(rootPath.ToString(), "addons"), "*.ifa"); var i = 0; foreach (var f in files) { ProcessPbo(f, tempPath, destination); i++; status.Update(null, (double)i / files.Length * 100); } }
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()); }
public void CopyDirectoryWithRetry(IAbsoluteDirectoryPath sourceFolder, IAbsoluteDirectoryPath outputFolder, bool overwrite = false) { var di = sourceFolder.DirectoryInfo; outputFolder.MakeSurePathExists(); CopyDirectoryFilesWithRetry(outputFolder, di, overwrite); foreach (var directory in di.EnumerateDirectories("*.*", SearchOption.AllDirectories)) { CopyDirectoryFilesWithRetry( outputFolder.GetChildDirectoryWithName(directory.FullName.Replace(sourceFolder + "\\", string.Empty)), directory, overwrite); } }
void HandleUserConfigPath(IAbsoluteDirectoryPath dir, IAbsoluteDirectoryPath userConfigPath) { var files = userConfigPath.DirectoryInfo.EnumerateFiles(); var directories = userConfigPath.DirectoryInfo.EnumerateDirectories(); var hasFiles = files.Any(); var hasDirectories = directories.Any(); if (hasFiles && hasDirectories) { throw new NotSupportedException( "The userconfig folder contains both files and folders, unable to detect what type it is"); } var storePath = dir.GetChildDirectoryWithName("store"); if (hasFiles) HandleUserconfigFiles(userConfigPath, storePath, files); else HandleUserconfigDirectories(userConfigPath, storePath, directories); }
string ProcessUserconfigInternal(IAbsoluteDirectoryPath modPath, IAbsoluteDirectoryPath gamePath, string exisitingChecksum, bool force = true) { if (modPath == null) { throw new ArgumentNullException(nameof(modPath)); } if (gamePath == null) { throw new ArgumentNullException(nameof(gamePath)); } var backupAndClean = force; var path = GetUserconfigPath(modPath); if (!File.Exists(path) && !Directory.Exists(path)) { return(null); } this.Logger().Info("Found userconfig to process at " + path); var checksum = GetConfigChecksum(path); if (checksum != exisitingChecksum) { backupAndClean = true; } var uconfig = gamePath.GetChildDirectoryWithName("userconfig"); var uconfigPath = uconfig.GetChildDirectoryWithName(GetRepoName(modPath.DirectoryName)); if (backupAndClean) { new UserconfigBackupAndClean().ProcessBackupAndCleanInstall(path, gamePath, uconfig, uconfigPath); } else { new UserconfigUpdater().ProcessMissingFiles(path, gamePath, uconfig, uconfigPath); } return(checksum); }
public SteamDirectories(uint appId, string folder, IAbsoluteDirectoryPath steamPath) { if (!(appId > 0)) { throw new ArgumentNullException("appId > 0"); } if (folder == null) { throw new ArgumentNullException(nameof(folder)); } if (steamPath == null) { throw new ArgumentNullException(nameof(steamPath)); } // TODO: Take LibraryPath from KV store RootPath = steamPath.GetChildDirectoryWithName("steamapps"); Game = new SteamGameDirectories(folder, RootPath); Workshop = new SteamWorkshopDirectories(appId, RootPath); }
public async Task GetMod(GroupContent mod, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, IAuthProvider provider, bool force = false) { var folder = destination.GetChildDirectoryWithName(mod.PackageName); if (!folder.Exists) { await InstallNew(mod, provider, GetOpts(packPath, status, mod), folder).ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) { return; } await UpdateExisting(mod, provider, rsyncDir, folder, GetOpts(packPath, status, mod)).ConfigureAwait(false); }
public IAbsoluteDirectoryPath GetRepoPath(string repoDirectory, IAbsoluteDirectoryPath directory, bool local = false) { if (string.IsNullOrWhiteSpace(repoDirectory)) { repoDirectory = directory.GetChildDirectoryWithName(Repository.DefaultRepoRootDirectory).ToString(); if (!Directory.Exists(repoDirectory)) { var dir = Tools.FileUtil.FindPathInParents(directory.ToString(), Repository.DefaultRepoRootDirectory); if ((dir != null) && Directory.Exists(dir)) { repoDirectory = dir; } else if (local) { repoDirectory = directory.ToString(); } } } return(Legacy.SixSync.Repository.RepoTools.GetRootedPath(repoDirectory)); }
// TODO: localOnly if no update available? - so for local diagnose etc.. public async Task GetMod(string name, IAbsoluteDirectoryPath destination, IAbsoluteDirectoryPath packPath, StatusRepo status, bool force = false) { var mod = GetMod(name); var folder = destination.GetChildDirectoryWithName(mod.Key); var config = GetOpts(packPath, status, mod); if (!folder.Exists) { var opts = new SyncOptions(); config(opts); await Repository.Factory.Clone(opts.Hosts, folder.ToString(), config) .ConfigureAwait(false); return; } var rsyncDir = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (!force && rsyncDir.Exists && IsRightVersion(rsyncDir, mod)) return; var repo = GetRepo(rsyncDir, folder, config); await repo.Update(config).ConfigureAwait(false); }
internal Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection<Uri> hosts, SyncOptions opts) { var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName); if (rsyncFolder.Exists) throw new Exception("Already appears to be a repository"); var packFolder = GetPackFolder(opts, rsyncFolder); var configFile = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName); var wdVersionFile = rsyncFolder.GetChildFileWithName(Repository.VersionFileName); var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName); this.Logger().Info("Initializing {0}", folder); rsyncFolder.MakeSurePathExists(); packFolder.MakeSurePathExists(); var config = new RepoConfig { Hosts = hosts.ToList() }; config.PackPath = opts.PackPath?.ToString(); if (opts.Include != null) config.Include = opts.Include; if (opts.Exclude != null) config.Include = opts.Exclude; var guid = opts.RequiredGuid ?? Guid.NewGuid().ToString(); var packVersion = new RepoVersion { Guid = guid }; if (opts.ArchiveFormat != null) packVersion.ArchiveFormat = (string)opts.ArchiveFormat; var wdVersion = SyncEvilGlobal.Yaml.NewFromYaml<RepoVersion>(packVersion.ToYaml()); SyncEvilGlobal.Yaml.ToYamlFile(config, configFile); SyncEvilGlobal.Yaml.ToYamlFile(packVersion, packVersionFile); SyncEvilGlobal.Yaml.ToYamlFile(wdVersion, wdVersionFile); return TryGetRepository(folder, opts, rsyncFolder); }
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(); }
private static IAbsoluteDirectoryPath GetPackFolder(SyncOptions opts, IAbsoluteDirectoryPath rsyncFolder) => opts.PackPath ?? rsyncFolder.GetChildDirectoryWithName(Repository.PackFolderName);
static void InstallFolder(IAbsoluteDirectoryPath pluginPath, IAbsoluteDirectoryPath tsPluginFolder, bool force) { Contract.Requires<ArgumentNullException>(tsPluginFolder != null); Contract.Requires<ArgumentNullException>(pluginPath != null); if (!pluginPath.IsNotNullAndExists()) throw new PathDoesntExistException(pluginPath.ToString()); if (!tsPluginFolder.IsNotNullAndExists()) throw new PathDoesntExistException(tsPluginFolder.ToString()); TryCopyFolder(pluginPath, tsPluginFolder.GetChildDirectoryWithName(pluginPath.DirectoryName), force); }
Action<SyncOptions> GetOpts(IAbsoluteDirectoryPath packPath, StatusRepo status, GroupContent mod) => opts => { opts.Hosts = GetHosts(mod).ToList(); //{"required_version", mod.Version}, // TODO //{"required_guid", @group.Id}, // TODO opts.PackPath = packPath.GetChildDirectoryWithName(mod.PackageName); opts.Status = status; };
private IAbsolutePath GetPath(IAbsoluteDirectoryPath workshopPath) => IsLegacy() ? (IAbsolutePath) workshopPath.GetChildFileWithName(Pid.ToString()) : workshopPath.GetChildDirectoryWithName(Pid.ToString());
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); }
void HandleArma1(ICollection<Game> existingGames, IAbsoluteDirectoryPath aiaModPath) { var a1 = existingGames.FirstOrDefault(g => g.Id == GameUuids.Arma1); if (a1 == null) return; existingGames.Remove(a1); AddGameDefaultAndAdditionalModFolders(a1, _additionalAiA); _additionalAiA.Add(aiaModPath.GetChildDirectoryWithName(AllInArmaA1Dummies)); }
static void InstallFolder(IAbsoluteDirectoryPath di, IAbsoluteDirectoryPath destination, string subPath, bool force) { Contract.Requires<ArgumentNullException>(destination != null); if (!destination.Exists) throw new PathDoesntExistException(destination.ToString()); if (subPath != null) destination = destination.GetChildDirectoryWithName(subPath); TryCopyFolder(di, destination.GetChildDirectoryWithName(di.DirectoryName), force); }
public SteamGameDirectories(string folder, IAbsoluteDirectoryPath rootPath) { RootPath = rootPath.GetChildDirectoryWithName("common"); ContentPath = RootPath.GetChildDirectoryWithName(folder); }
void SetPaths(ISupportModding game) { _rootPath = GetModRootPath(game); Path = _rootPath != null ? _rootPath.GetChildDirectoryWithName(_mod.Name) : null; }
void ExtractFolder(IAbsoluteDirectoryPath rootPath, IAbsoluteDirectoryPath tempPath, IAbsoluteDirectoryPath destination, IStatus status) { destination = destination.GetChildDirectoryWithName("addons"); destination.MakeSurePathExists(); var files = Directory.GetFiles(Path.Combine(rootPath.ToString(), "addons"), "*.ifa"); var i = 0; foreach (var f in files) { ProcessPbo(f, tempPath, destination); i++; status.Update(null, ((double)i / files.Length) * 100); } }
public SteamWorkshopDirectories(uint appId, IAbsoluteDirectoryPath rootPath) { RootPath = rootPath.GetChildDirectoryWithName("workshop"); ContentPath = RootPath.GetChildDirectoryWithName("content").GetChildDirectoryWithName(appId.ToString()); }
static IAbsoluteDirectoryPath GetPluginPath(IAbsoluteDirectoryPath tsPath) { return tsPath.GetChildDirectoryWithName(Ts3SubPath); }