mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Update unsafe file write usages
This commit is contained in:
parent
f78eb0066c
commit
218642c300
@ -507,7 +507,7 @@ namespace osu.Game.Tests.Database
|
|||||||
using (var stream = storage.GetStream(firstFile.File.GetStoragePath()))
|
using (var stream = storage.GetStream(firstFile.File.GetStoragePath()))
|
||||||
originalLength = stream.Length;
|
originalLength = stream.Length;
|
||||||
|
|
||||||
using (var stream = storage.GetStream(firstFile.File.GetStoragePath(), FileAccess.Write, FileMode.Create))
|
using (var stream = storage.CreateFileSafely(firstFile.File.GetStoragePath()))
|
||||||
stream.WriteByte(0);
|
stream.WriteByte(0);
|
||||||
|
|
||||||
var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm);
|
var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -25,7 +24,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
if (isDisposing)
|
if (isDisposing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using (var outStream = LocalStorage.GetStream(DatabaseContextFactory.DATABASE_NAME, FileAccess.Write, FileMode.Create))
|
using (var outStream = LocalStorage.CreateFileSafely(DatabaseContextFactory.DATABASE_NAME))
|
||||||
using (var stream = TestResources.OpenResource(DatabaseContextFactory.DATABASE_NAME))
|
using (var stream = TestResources.OpenResource(DatabaseContextFactory.DATABASE_NAME))
|
||||||
stream.CopyTo(outStream);
|
stream.CopyTo(outStream);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
|||||||
// ReSharper disable once AccessToDisposedClosure
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
var storage = host.Storage.GetStorageForDirectory(Path.Combine("tournaments", "default"));
|
var storage = host.Storage.GetStorageForDirectory(Path.Combine("tournaments", "default"));
|
||||||
|
|
||||||
using (var stream = storage.GetStream("bracket.json", FileAccess.Write, FileMode.Create))
|
using (var stream = storage.CreateFileSafely("bracket.json"))
|
||||||
using (var writer = new StreamWriter(stream))
|
using (var writer = new StreamWriter(stream))
|
||||||
{
|
{
|
||||||
writer.Write(@"{
|
writer.Write(@"{
|
||||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Tournament.Tests.Screens
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(Storage storage)
|
private void load(Storage storage)
|
||||||
{
|
{
|
||||||
using (var stream = storage.GetStream("drawings.txt", FileAccess.Write))
|
using (var stream = storage.CreateFileSafely("drawings.txt"))
|
||||||
using (var writer = new StreamWriter(stream))
|
using (var writer = new StreamWriter(stream))
|
||||||
{
|
{
|
||||||
writer.WriteLine("KR : South Korea : KOR");
|
writer.WriteLine("KR : South Korea : KOR");
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Tournament.Models
|
|||||||
|
|
||||||
public void SaveChanges()
|
public void SaveChanges()
|
||||||
{
|
{
|
||||||
using (var stream = configStorage.GetStream(config_path, FileAccess.Write, FileMode.Create))
|
using (var stream = configStorage.CreateFileSafely(config_path))
|
||||||
using (var sw = new StreamWriter(stream))
|
using (var sw = new StreamWriter(stream))
|
||||||
{
|
{
|
||||||
sw.Write(JsonConvert.SerializeObject(this,
|
sw.Write(JsonConvert.SerializeObject(this,
|
||||||
|
@ -205,7 +205,7 @@ namespace osu.Game.Tournament.Screens.Drawings
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Write to drawings_results
|
// Write to drawings_results
|
||||||
using (Stream stream = storage.GetStream(results_filename, FileAccess.Write, FileMode.Create))
|
using (Stream stream = storage.CreateFileSafely(results_filename))
|
||||||
using (StreamWriter sw = new StreamWriter(stream))
|
using (StreamWriter sw = new StreamWriter(stream))
|
||||||
{
|
{
|
||||||
sw.Write(text);
|
sw.Write(text);
|
||||||
|
@ -321,7 +321,7 @@ namespace osu.Game.Tournament
|
|||||||
Converters = new JsonConverter[] { new JsonPointConverter() }
|
Converters = new JsonConverter[] { new JsonPointConverter() }
|
||||||
});
|
});
|
||||||
|
|
||||||
using (var stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Write, FileMode.Create))
|
using (var stream = storage.CreateFileSafely(BRACKET_FILENAME))
|
||||||
using (var sw = new StreamWriter(stream))
|
using (var sw = new StreamWriter(stream))
|
||||||
sw.Write(serialisedLadder);
|
sw.Write(serialisedLadder);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
string filename = $"{item.GetDisplayString().GetValidArchiveContentFilename()}{FileExtension}";
|
string filename = $"{item.GetDisplayString().GetValidArchiveContentFilename()}{FileExtension}";
|
||||||
|
|
||||||
using (var stream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create))
|
using (var stream = exportStorage.CreateFileSafely(filename))
|
||||||
ExportModelTo(item, stream);
|
ExportModelTo(item, stream);
|
||||||
|
|
||||||
exportStorage.PresentFileExternally(filename);
|
exportStorage.PresentFileExternally(filename);
|
||||||
|
@ -242,7 +242,7 @@ namespace osu.Game.Database
|
|||||||
storage.Delete(Filename);
|
storage.Delete(Filename);
|
||||||
|
|
||||||
using (var inputStream = storage.GetStream(recoveryFilename))
|
using (var inputStream = storage.GetStream(recoveryFilename))
|
||||||
using (var outputStream = storage.GetStream(Filename, FileAccess.Write, FileMode.Create))
|
using (var outputStream = storage.CreateFileSafely(Filename))
|
||||||
inputStream.CopyTo(outputStream);
|
inputStream.CopyTo(outputStream);
|
||||||
|
|
||||||
storage.Delete(recoveryFilename);
|
storage.Delete(recoveryFilename);
|
||||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
if (filename == null) return;
|
if (filename == null) return;
|
||||||
|
|
||||||
using (var stream = storage.GetStream(filename, FileAccess.Write))
|
using (var stream = storage.CreateFileSafely(filename))
|
||||||
{
|
{
|
||||||
switch (screenshotFormat.Value)
|
switch (screenshotFormat.Value)
|
||||||
{
|
{
|
||||||
|
@ -243,7 +243,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
if (source != null)
|
if (source != null)
|
||||||
{
|
{
|
||||||
using (var destination = Storage.GetStream(Path.Combine(backup_folder, $"collection.{migration}.db"), FileAccess.Write, FileMode.CreateNew))
|
using (var destination = Storage.CreateFileSafely(Path.Combine(backup_folder, $"collection.{migration}.db")))
|
||||||
source.CopyTo(destination);
|
source.CopyTo(destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Stores
|
|||||||
{
|
{
|
||||||
data.Seek(0, SeekOrigin.Begin);
|
data.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
using (var output = Storage.GetStream(file.GetStoragePath(), FileAccess.Write))
|
using (var output = Storage.CreateFileSafely(file.GetStoragePath()))
|
||||||
data.CopyTo(output);
|
data.CopyTo(output);
|
||||||
|
|
||||||
data.Seek(0, SeekOrigin.Begin);
|
data.Seek(0, SeekOrigin.Begin);
|
||||||
|
Loading…
Reference in New Issue
Block a user