public void Save(ES3Settings settings, bool append) { using (var writer = new StreamWriter(ES3Stream.CreateStream(settings, append ? ES3FileMode.Append : ES3FileMode.Write))) { // If data already exists and we're appending, we need to prepend a newline. if (append && ES3.FileExists(settings)) { writer.Write(NEWLINE_CHAR); } var array = ToArray(); for (int row = 0; row < rows; row++) { if (row != 0) { writer.Write(NEWLINE_CHAR); } for (int col = 0; col < cols; col++) { if (col != 0) { writer.Write(COMMA_CHAR); } writer.Write(Escape(array [col, row])); } } } if (!append) { ES3IO.CommitBackup(settings); } }
/// <summary>Creates or overwrites a file with the specified raw bytes.</summary> /// <param name="bytes">The bytes we want to store.</param> /// <param name="settings">The settings we want to use to override the default settings.</param> public static void SaveRaw(byte[] bytes, ES3Settings settings) { using (var stream = ES3Stream.CreateStream(settings, ES3FileMode.Write)) { stream.Write(bytes, 0, bytes.Length); } ES3IO.CommitBackup(settings); }
/// <summary>Stores the contents of the writer and overwrites any existing keys if overwriting is enabled.</summary> /// <param name="overwriteKeys">Whether we should overwrite existing keys.</param> public virtual void Save(bool overwriteKeys) { if (overwriteKeys) { Merge(); } EndWriteFile(); Dispose(); // If we're writing to a location which can become corrupted, rename the backup file to the file we want. // This prevents corrupt data. ES3IO.CommitBackup(settings); }
public void Save(ES3Settings settings, bool append) { using (var writer = new StreamWriter(ES3Stream.CreateStream(settings, append ? ES3FileMode.Append : ES3FileMode.Write))) { var array = ToArray(); for (int row = 0; row < rows; row++) { if (row != 0) { writer.Write('\n'); } for (int col = 0; col < cols; col++) { if (col != 0) { writer.Write(','); } writer.Write(Escape(array [col, row])); } } } ES3IO.CommitBackup(settings); }