mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +00:00
Merge pull request #755 from KingLuigi4932/patch-3
Fixing WriteAllLines issue
This commit is contained in:
commit
cf08368c9e
2 changed files with 17 additions and 24 deletions
|
|
@ -617,20 +617,18 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
mDebugger.Send("END TEST");
|
||||
mDebugger.Send("");
|
||||
}
|
||||
|
||||
// Generic methods on arrays don't work, see https://github.com/CosmosOS/Cosmos/issues/583
|
||||
//
|
||||
//string[] contents = { "One", "Two", "Three" };
|
||||
//File.WriteAllLines(@"0:\test3.txt", contents);
|
||||
//mDebugger.Send("Text written");
|
||||
//mDebugger.Send("Now reading with ReadAllLines()");
|
||||
//string[] readLines = File.ReadAllLines(@"0:\test3.txt");
|
||||
//mDebugger.Send("Contents retrieved after writing");
|
||||
//for (int i = 0; i < readLines.Length; i++)
|
||||
//{
|
||||
// mDebugger.Send(readLines[i]);
|
||||
//}
|
||||
//Assert.IsTrue(StringArrayAreEquals(contents, readLines), "Contents of test3.txt was written incorrectly!");
|
||||
|
||||
string[] contents = { "One", "Two", "Three" };
|
||||
File.WriteAllLines(@"0:\test3.txt", contents);
|
||||
mDebugger.Send("Text written");
|
||||
mDebugger.Send("Now reading with ReadAllLines()");
|
||||
string[] readLines = File.ReadAllLines(@"0:\test3.txt");
|
||||
mDebugger.Send("Contents retrieved after writing");
|
||||
for (int i = 0; i < readLines.Length; i++)
|
||||
{
|
||||
mDebugger.Send(readLines[i]);
|
||||
}
|
||||
Assert.IsTrue(StringArrayAreEquals(contents, readLines), "Contents of test3.txt was written incorrectly!");
|
||||
#if false
|
||||
// TODO maybe the more correct test is to implement ReadAllLines and then check that two arrays are equals
|
||||
var xContents = File.ReadAllText(@"0:\test3.txt");
|
||||
|
|
|
|||
|
|
@ -119,19 +119,14 @@ namespace Cosmos.System_Plugs.System.IO
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void WriteAllLines(string aFile, IEnumerable<string> contents)
|
||||
|
||||
public static void WriteAllLines(string aFile, string[] contents)
|
||||
{
|
||||
string text = null;
|
||||
|
||||
foreach (var line in contents)
|
||||
{
|
||||
text = string.Concat(text, line, Environment.NewLine);
|
||||
}
|
||||
|
||||
string text = String.Join(Environment.NewLine, contents);
|
||||
|
||||
Global.mFileSystemDebugger.SendInternal("Writing contents");
|
||||
Global.mFileSystemDebugger.SendInternal(text);
|
||||
|
||||
|
||||
WriteAllText(aFile, text);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue