mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Tidy up config parsing logic
This commit is contained in:
parent
5f23bd7259
commit
8ab7d07eab
@ -23,6 +23,7 @@ namespace osu.Game.IO
|
|||||||
: base(path, host)
|
: base(path, host)
|
||||||
{
|
{
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
|
||||||
songsPath = new Lazy<string>(locateSongsDirectory);
|
songsPath = new Lazy<string>(locateSongsDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,13 +34,10 @@ namespace osu.Game.IO
|
|||||||
|
|
||||||
private string locateSongsDirectory()
|
private string locateSongsDirectory()
|
||||||
{
|
{
|
||||||
var songsDirectoryPath = Path.Combine(BasePath, stable_default_songs_path);
|
|
||||||
|
|
||||||
var configFile = GetFiles(".", $"osu!.{Environment.UserName}.cfg").SingleOrDefault();
|
var configFile = GetFiles(".", $"osu!.{Environment.UserName}.cfg").SingleOrDefault();
|
||||||
|
|
||||||
if (configFile == null)
|
if (configFile != null)
|
||||||
return songsDirectoryPath;
|
{
|
||||||
|
|
||||||
using (var stream = GetStream(configFile))
|
using (var stream = GetStream(configFile))
|
||||||
using (var textReader = new StreamReader(stream))
|
using (var textReader = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
@ -47,18 +45,18 @@ namespace osu.Game.IO
|
|||||||
|
|
||||||
while ((line = textReader.ReadLine()) != null)
|
while ((line = textReader.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
if (line.StartsWith("BeatmapDirectory", StringComparison.OrdinalIgnoreCase))
|
if (!line.StartsWith("BeatmapDirectory", StringComparison.OrdinalIgnoreCase)) continue;
|
||||||
{
|
|
||||||
var directory = line.Split('=')[1].TrimStart();
|
var customDirectory = line.Split('=').LastOrDefault()?.Trim();
|
||||||
if (Path.IsPathFullyQualified(directory))
|
if (customDirectory != null && Path.IsPathFullyQualified(customDirectory))
|
||||||
songsDirectoryPath = directory;
|
return customDirectory;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return songsDirectoryPath;
|
return GetFullPath(stable_default_songs_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user