public override void Load() { if (!PlatformAPISettings.Running) { return; } try { this.manifest = SaveFileManifest.Deserialize((IStorageMethod)this); } catch (NullReferenceException ex) { } catch (FormatException ex) { } if (this.manifest == null) { this.manifest = new SaveFileManifest(); this.manifest.Save((IStorageMethod)this, false); } else { this.deserialized = true; } }
public override void Load() { FolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/My Games/Hacknet/Accounts/"; if (!Directory.Exists(FolderPath)) { Directory.CreateDirectory(FolderPath); } try { manifest = SaveFileManifest.Deserialize(this); } catch (FormatException ex) { manifest = null; } catch (NullReferenceException ex) { manifest = null; } if (manifest == null) { manifest = new SaveFileManifest(); manifest.Save(this); } else { deserialized = true; } }
private static SaveFileManifest ReadOldSysemLocalSaveManifest() { var saveReadStream = RemoteSaveStorage.GetSaveReadStream("_accountsMeta", true); if (saveReadStream == null) { return(null); } var data = new StreamReader(saveReadStream).ReadToEnd(); saveReadStream.Close(); saveReadStream.Dispose(); return(SaveFileManifest.Deserialize(data)); }
public override void Load() { if (!PlatformAPISettings.Running) { return; } manifest = SaveFileManifest.Deserialize(this); if (manifest == null) { manifest = new SaveFileManifest(); manifest.Save(this); } else { deserialized = true; } }
public static SaveFileManifest Deserialize(IStorageMethod storage) { if (!storage.FileExists("Accounts.txt")) { return((SaveFileManifest)null); } SaveFileManifest saveFileManifest = (SaveFileManifest)null; using (Stream fileReadStream = storage.GetFileReadStream("Accounts.txt")) { string end = new StreamReader(fileReadStream).ReadToEnd(); if (!string.IsNullOrEmpty(end.Trim())) { saveFileManifest = SaveFileManifest.Deserialize(end); } } return(saveFileManifest); }
public override void Load() { string platform = SDL.SDL_GetPlatform(); if (platform.Equals("Linux")) { this.FolderPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME"); if (string.IsNullOrEmpty(this.FolderPath)) { this.FolderPath = Environment.GetEnvironmentVariable("HOME"); if (string.IsNullOrEmpty(this.FolderPath)) { this.FolderPath = "./"; } else { this.FolderPath += "/.local/share/Hacknet/Accounts/"; } } else { this.FolderPath += "/Hacknet/Accounts/"; } } else if (platform.Equals("Mac OS X")) { this.FolderPath = Environment.GetEnvironmentVariable("HOME"); if (string.IsNullOrEmpty(this.FolderPath)) { this.FolderPath = "./"; } else { this.FolderPath += "/Library/Application Support/Hacknet/Accounts/"; } } else { if (!platform.Equals("Windows")) { throw new NotSupportedException("Unhandled SDL2 platform!"); } this.FolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/My Games/Hacknet/Accounts/"; } try { if (!Directory.Exists(this.FullFolderPath)) { Directory.CreateDirectory(this.FullFolderPath); } } catch (UnauthorizedAccessException ex) { Utils.AppendToErrorFile("Local Documents Storage load error : Insufficient permissions for folder access.\r\n" + Utils.GenerateReportFromException((Exception)ex)); this.FolderPath = "Accounts/"; MainMenu.AccumErrors = MainMenu.AccumErrors + "\r\nERROR: Local Documents Storage Folder is refusing access. Saving accounts to:\r\n" + Path.GetFullPath(this.FolderPath); } try { this.manifest = SaveFileManifest.Deserialize((IStorageMethod)this); } catch (FormatException ex) { this.manifest = (SaveFileManifest)null; Console.WriteLine("Local Save Manifest Corruption: " + Utils.GenerateReportFromException((Exception)ex)); } catch (NullReferenceException ex) { this.manifest = (SaveFileManifest)null; Console.WriteLine("Local Save Manifest Corruption: " + Utils.GenerateReportFromException((Exception)ex)); } if (this.manifest == null) { this.manifest = new SaveFileManifest(); this.manifest.Save((IStorageMethod)this, true); } else { this.deserialized = true; } }