Skip to content

Commit 72dfbda

Browse files
committed
LynnaLib: Fix CRLF handling on Windows
LynnaLab previously wrote back files with CRLF line endings. The current version is unable to read back that style of newline, so old projects were broken. Now it can handle CRLF newlines, and it also doesn't write CRLF newlines back to the files it reads.
1 parent 500867a commit 72dfbda

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

LynnaLib/FileParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,8 @@ public void Save()
11781178
// where we loaded through a MemoryFileStream. Doesn't really matter since saving only
11791179
// works on the server anyway. It does mean the MemoryFileStream will be out of sync
11801180
// with the file itself though - not that that should matter at all.
1181-
File.WriteAllLines(FullFilename, output);
1181+
// Don't use WriteAllLines as that writes CRLF on windows.
1182+
File.WriteAllText(FullFilename, string.Join('\n', output));
11821183

11831184
Modified = false;
11841185
}

LynnaLib/MemoryFileStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public int GetByte(int position)
282282

283283
public string ReadAllText()
284284
{
285-
return System.Text.Encoding.UTF8.GetString(Data);
285+
return System.Text.Encoding.UTF8.GetString(Data).Replace("\r\n", "\n");
286286
}
287287
public string[] ReadAllLines()
288288
{

0 commit comments

Comments
 (0)