Replace any potential usage of Environment.CurrentDirectory with a new RuntimeInfo.StartupDirectory

Using `Environment.CurrentDirectory` for storing / reading files is dangerous as the current directory is mutable and can be changed when performing a certain operation (like opening solutions in roslyn type reference builder for example).
This commit is contained in:
Salman Ahmed
2020-05-31 02:18:07 +03:00
parent e64e44ecf9
commit 82fe99cf4a
5 changed files with 17 additions and 16 deletions

View File

@ -3,6 +3,7 @@
using System.IO;
using NUnit.Framework;
using osu.Framework;
using osu.Framework.IO.Stores;
namespace osu.Game.Tests.Resources
@ -20,10 +21,10 @@ namespace osu.Game.Tests.Resources
var temp = Path.GetTempFileName() + ".osz";
using (var stream = GetTestBeatmapStream(virtualTrack))
using (var newFile = File.Create(temp))
using (var newFile = RuntimeInfo.StartupStorage.GetStream(temp, FileAccess.Write))
stream.CopyTo(newFile);
Assert.IsTrue(File.Exists(temp));
Assert.IsTrue(RuntimeInfo.StartupStorage.Exists(temp));
return temp;
}
}