public void Validate(Metadata metadata) { var json = metadata.Json(); if (json.ContainsKey("install")) { foreach (JObject stanza in json["install"]) { string install_to = (string)stanza["install_to"]; if (metadata.SpecVersion < v1p2 && install_to.StartsWith("GameData/")) { throw new Kraken("spec_version v1.2+ required for GameData with path"); } if (metadata.SpecVersion < v1p29 && install_to.StartsWith("Ships/Script")) { throw new Kraken("spec_version v1.29+ required to install to Ships/Script"); } if (metadata.SpecVersion < v1p12 && install_to.StartsWith("Ships/")) { throw new Kraken("spec_version v1.12+ required to install to Ships/ with path"); } if (metadata.SpecVersion < v1p16 && install_to.StartsWith("Ships/@thumbs")) { throw new Kraken("spec_version v1.16+ required to install to Ships/@thumbs with path"); } if (metadata.SpecVersion < v1p4 && stanza.ContainsKey("find")) { throw new Kraken("spec_version v1.4+ required for install with 'find'"); } if (metadata.SpecVersion < v1p10 && stanza.ContainsKey("find_regexp")) { throw new Kraken("spec_version v1.10+ required for install with 'find_regexp'"); } if (metadata.SpecVersion < v1p16 && stanza.ContainsKey("find_matches_files")) { throw new Kraken("spec_version v1.16+ required for 'find_matches_files'"); } if (metadata.SpecVersion < v1p18 && stanza.ContainsKey("as")) { throw new Kraken("spec_version v1.18+ required for 'as'"); } // Check for normalized paths foreach (string propName in pathProperties) { if (stanza.ContainsKey(propName)) { string val = (string)stanza[propName]; string norm = CKANPathUtils.NormalizePath(val); if (val != norm) { throw new Kraken($"Path \"{val}\" in '{propName}' is not normalized, should be \"{norm}\""); } } } } } }
/// <summary> /// Finds the Steam KSP path. Returns null if the folder cannot be located. /// </summary> /// <returns>The KSP path.</returns> public string SteamPath() { // Attempt to get the Steam path. string steamPath = CKANPathUtils.SteamPath(); if (steamPath == null) { return(null); } // Default steam library string installPath = KSPDirectory(steamPath); if (installPath != null) { return(installPath); } // Attempt to find through config file string configPath = Path.Combine(steamPath, "config", "config.vdf"); if (File.Exists(configPath)) { log.InfoFormat("Found Steam config file at {0}", configPath); StreamReader reader = new StreamReader(configPath); string line; while ((line = reader.ReadLine()) != null) { // Found Steam library if (line.Contains("BaseInstallFolder")) { // This assumes config file is valid, we just skip it if it looks funny. string[] split_line = line.Split('"'); if (split_line.Length > 3) { log.DebugFormat("Found a Steam Libary Location at {0}", split_line[3]); installPath = KSPDirectory(split_line[3]); if (installPath != null) { log.InfoFormat("Found a KSP install at {0}", installPath); return(installPath); } } } } } // Could not locate the folder. return(null); }
public string PrimaryModDirectory(GameInstance inst) { return(CKANPathUtils.NormalizePath( Path.Combine(inst.GameDir(), PrimaryModDirectoryRelative))); }
private string Scenarios(GameInstance inst) { return(CKANPathUtils.NormalizePath( Path.Combine(inst.GameDir(), "saves", "scenarios"))); }
private string Tutorial(GameInstance inst) { return(CKANPathUtils.NormalizePath( Path.Combine(inst.GameDir(), "saves", "training"))); }
private string ShipsScript(GameInstance inst) { return(CKANPathUtils.NormalizePath( Path.Combine(Ships(inst), "Script"))); }
private string ShipsThumbsVAB(GameInstance inst) { return(CKANPathUtils.NormalizePath( Path.Combine(ShipsThumbs(inst), "VAB"))); }
private string Ships(GameInstance inst) { return(CKANPathUtils.NormalizePath( Path.Combine(inst.GameDir(), "Ships"))); }