General improvements

This commit is contained in:
Alex Amadori
2017-03-13 11:29:24 +01:00
parent 971d8eb7c5
commit caa6e9c82b
7 changed files with 10 additions and 7 deletions

View File

@ -10,6 +10,7 @@ namespace osu.Game.Beatmaps.IO
{
public abstract class BeatmapArchiveReader : ArchiveReader
{
public const string OszExtension = @".osz";
public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path)
{
@ -19,7 +20,7 @@ namespace osu.Game.Beatmaps.IO
}
catch (InvalidCastException e)
{
Logger.Error(e, "A tricky ArchiveReader instance passed the test to be a BeatmapArhiveReader, but it's really not");
Logger.Error(e, "A tricky " + $@"{nameof(ArchiveReader)}" + " instance passed the test to be a " + $@"{nameof(BeatmapArchiveReader)}" + ", but it's really not");
throw;
}
}

View File

@ -16,7 +16,7 @@ namespace osu.Game.Beatmaps.IO
AddReader<OszArchiveReader>((storage, path) =>
{
using (var stream = storage.GetStream(path))
return Path.GetExtension(path) == ".osz" && ZipFile.IsZipFile(stream, false);
return Path.GetExtension(path) == OszExtension && ZipFile.IsZipFile(stream, false);
});
OsuLegacyDecoder.Register();
}

View File

@ -186,7 +186,7 @@ namespace osu.Game.Database
{
hash = input.GetMd5Hash();
input.Seek(0, SeekOrigin.Begin);
path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash+".osz");
path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OszExtension);
if (!storage.Exists(path))
using (var output = storage.GetStream(path, FileAccess.Write))
input.CopyTo(output);

View File

@ -327,7 +327,7 @@
<Compile Include="Screens\Select\Options\BeatmapOptionsEditButton.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
<Compile Include="Screens\Select\Options\BeatmapOptionsRemoveFromUnplayedButton.cs" />
<Compile Include="Beatmaps\IO\ArchiveReader.cs" />
<Compile Include="IO\ArchiveReader.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">