mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 19:53:23 +08:00
Refactor moving logic (1/2)
This commit is contained in:
parent
29ae1c460a
commit
b75fd7bfa8
@ -57,34 +57,11 @@ namespace osu.Game.Tournament.IO
|
|||||||
|
|
||||||
if (!cfgDestination.Exists)
|
if (!cfgDestination.Exists)
|
||||||
destination.CreateSubdirectory(config_directory);
|
destination.CreateSubdirectory(config_directory);
|
||||||
|
|
||||||
if (storage.Exists("bracket.json"))
|
moveFileIfExists("bracket.json", destination);
|
||||||
{
|
moveFileIfExists("drawings.txt", destination);
|
||||||
Logger.Log("Migrating bracket to default tournament storage.");
|
moveFileIfExists("drawings_results.txt", destination);
|
||||||
var bracketFile = new System.IO.FileInfo(storage.GetFullPath("bracket.json"));
|
moveFileIfExists("drawings.ini", cfgDestination);
|
||||||
moveFile(bracketFile, destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (storage.Exists("drawings.txt"))
|
|
||||||
{
|
|
||||||
Logger.Log("Migrating drawings to default tournament storage.");
|
|
||||||
var drawingsFile = new System.IO.FileInfo(storage.GetFullPath("drawings.txt"));
|
|
||||||
moveFile(drawingsFile, destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (storage.Exists("drawings.ini"))
|
|
||||||
{
|
|
||||||
Logger.Log("Migrating drawing configuration to default tournament storage.");
|
|
||||||
var drawingsConfigFile = new System.IO.FileInfo(storage.GetFullPath("drawings.ini"));
|
|
||||||
moveFile(drawingsConfigFile, cfgDestination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (storage.Exists("drawings_results.txt"))
|
|
||||||
{
|
|
||||||
Logger.Log("Migrating drawings results to default tournament storage.");
|
|
||||||
var drawingsResultsFile = new System.IO.FileInfo(storage.GetFullPath("drawings_results.txt"));
|
|
||||||
moveFile(drawingsResultsFile, destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (source.Exists)
|
if (source.Exists)
|
||||||
{
|
{
|
||||||
@ -94,6 +71,16 @@ namespace osu.Game.Tournament.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveFileIfExists(string file, DirectoryInfo destination)
|
||||||
|
{
|
||||||
|
if (storage.Exists(file))
|
||||||
|
{
|
||||||
|
Logger.Log($"Migrating {file} to default tournament storage.");
|
||||||
|
var fileInfo = new System.IO.FileInfo(storage.GetFullPath(file));
|
||||||
|
moveFile(fileInfo, destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void copyRecursive(DirectoryInfo source, DirectoryInfo destination)
|
private void copyRecursive(DirectoryInfo source, DirectoryInfo destination)
|
||||||
{
|
{
|
||||||
// based off example code https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo
|
// based off example code https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo
|
||||||
|
Loading…
Reference in New Issue
Block a user