public static bool TestDataPath(string path, bool log) { if (Utils.HasAccessToWrite(path) == false) { if (log == true) { Engine.Instance.Logs.Log(LogType.Info, "Unable to write in path '" + path + "'"); } return(false); } return(true); }
public Storage() { EnsureDefaults(); // Compute profile string profile = Get("profile"); string path = Get("path"); path = Platform.Instance.NormalizePath(path); if (path == "") { path = Platform.Instance.GetDefaultDataPath(); } if (profile.IndexOf(".") != -1) { // Profile must not have an extension. profile = profile.Substring(0, profile.IndexOf(".")); CommandLine.SystemEnvironment.Set("profile", profile); } if (Platform.Instance.IsPath(profile)) { // Is a path FileInfo fi = new FileInfo(Platform.Instance.NormalizePath(profile)); DataPath = fi.DirectoryName; profile = fi.Name; CommandLine.SystemEnvironment.Set("profile", profile); if (TestDataPath(DataPath, true) == false) { DataPath = ""; } } if (DataPath == "") { if (path == "home") { path = Platform.Instance.GetUserFolder(); } else if (path == "program") { path = Platform.Instance.GetProgramFolder(); } if (path != "") { DataPath = path; if (TestDataPath(DataPath, true) == false) { DataPath = ""; } } } if (DataPath == "") { DataPath = Platform.Instance.GetProgramFolder(); if (Utils.HasAccessToWrite(DataPath) == false) { DataPath = ""; } } if (DataPath == "") { DataPath = Platform.Instance.GetUserFolder(); } }