private static void LogText(string logString) { File.AppendAllText(GetLogPath(), logString); if (new System.IO.FileInfo(GetLogPath()).Length > deleteThreshhold) { File.Delete(GetLogPath()); } SenseixSession.DoFileFlagging(GetLogPath()); }
static public void CopyFailsafeOver() { string failsafeFileName = "failsafe"; string failsafeDestination = System.IO.Path.Combine(Application.persistentDataPath, failsafeFileName + SEED_FILE_EXTENSION); TextAsset failsafeAsset = Resources.Load <TextAsset>(failsafeFileName); byte[] failsafeContents = failsafeAsset.bytes; try { FileStream newFile = System.IO.File.Create(failsafeDestination); SenseixSession.DoFileFlagging(failsafeDestination); newFile.Close(); System.IO.File.WriteAllBytes(failsafeDestination, failsafeContents); } catch { ThinksyPlugin.ShowEmergencyWindow("An error occurred while creating a failsafe seed file in " + failsafeDestination); } }
static private void ReplaceSeed(Message.Problem.ProblemGetResponse reply) { Logger.BasicLog("Replacing seed file."); MemoryStream stream = new MemoryStream(); ThinksyProtosSerializer customSerializer = new ThinksyProtosSerializer(); customSerializer.Serialize(stream, reply); byte[] replacementBytes = stream.ToArray(); try { FileStream newFile = System.IO.File.Create(PlayerSeedPath()); SenseixSession.DoFileFlagging(PlayerSeedPath()); newFile.Close(); } catch { ThinksyPlugin.ShowEmergencyWindow("An error occurred while creating a seedfile in " + PlayerSeedPath()); } stream.Close(); System.IO.File.WriteAllBytes(SeedFilePath(), replacementBytes); SenseixSession.DoFileFlagging(SeedFilePath()); }