mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
v1.30 UWP
This commit is contained in:
parent
ea0fa6b254
commit
02062c8b9c
3 changed files with 56 additions and 12 deletions
|
|
@ -112,6 +112,9 @@
|
|||
<EmbeddedResource Include="..\..\Data\library.db">
|
||||
<Link>library.db</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="..\..\Data\library.ver">
|
||||
<Link>library.ver</Link>
|
||||
</EmbeddedResource>
|
||||
<None Include="AideDeJeu.UWP_StoreKey.pfx" />
|
||||
<None Include="AideDeJeu.UWP_TemporaryKey.pfx" />
|
||||
<Content Include="Assets\Fonts\LinLibertine_R.ttf" />
|
||||
|
|
|
|||
|
|
@ -25,21 +25,62 @@ namespace AideDeJeu.UWP
|
|||
|
||||
public async Task<string> GetDatabasePathAsync(string databaseName)
|
||||
{
|
||||
var documentsDirectoryPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
|
||||
var path = Path.Combine(documentsDirectoryPath, $"{databaseName}.db");
|
||||
|
||||
if (!File.Exists(path))
|
||||
if (await CheckDatabaseVersionAsync(databaseName))
|
||||
{
|
||||
var assembly = typeof(Version_UWP).GetTypeInfo().Assembly;
|
||||
using (var inStream = assembly.GetManifestResourceStream($"AideDeJeu.UWP.{databaseName}.db"))
|
||||
await CopyOldToNewFileAsync(databaseName, "db");
|
||||
await CopyOldToNewFileAsync(databaseName, "ver");
|
||||
}
|
||||
return GetNewFilePath(databaseName, "db");
|
||||
}
|
||||
|
||||
public Stream GetOldFileStream(string fileName, string extension)
|
||||
{
|
||||
var assembly = typeof(Version_UWP).GetTypeInfo().Assembly;
|
||||
return assembly.GetManifestResourceStream($"AideDeJeu.UWP.{fileName}.{extension}");
|
||||
}
|
||||
public string GetNewFilePath(string fileName, string extension)
|
||||
{
|
||||
var documentsDirectoryPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
|
||||
return Path.Combine(documentsDirectoryPath, $"{fileName}.{extension}");
|
||||
}
|
||||
public async Task CopyOldToNewFileAsync(string fileName, string extension)
|
||||
{
|
||||
using (var inStream = GetOldFileStream(fileName, extension))
|
||||
{
|
||||
using (var outStream = new FileStream(GetNewFilePath(fileName, extension), FileMode.Create))
|
||||
{
|
||||
using (var outStream = new FileStream(path, FileMode.Create))
|
||||
{
|
||||
await inStream.CopyToAsync(outStream);
|
||||
}
|
||||
await inStream.CopyToAsync(outStream);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckDatabaseVersionAsync(string databaseName)
|
||||
{
|
||||
var path = GetNewFilePath(databaseName, "ver");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int newVersion = 0;
|
||||
int oldVersion = -1;
|
||||
using (var newStream = GetOldFileStream(databaseName, "ver"))
|
||||
{
|
||||
using (var sr = new StreamReader(newStream))
|
||||
{
|
||||
var str = await sr.ReadToEndAsync();
|
||||
int.TryParse(str, out newVersion);
|
||||
}
|
||||
}
|
||||
using (var oldStream = new FileStream(path, FileMode.Open))
|
||||
{
|
||||
using (var sr = new StreamReader(oldStream))
|
||||
{
|
||||
var str = await sr.ReadToEndAsync();
|
||||
int.TryParse(str, out oldVersion);
|
||||
}
|
||||
}
|
||||
return newVersion > oldVersion;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
||||
<Identity Name="7385YanManiez.AidedeJeu" Publisher="CN=2C78A91E-528B-4FF0-A4BE-FD7F7EBABB44" Version="1.29.0.0" />
|
||||
<Identity Name="7385YanManiez.AidedeJeu" Publisher="CN=2C78A91E-528B-4FF0-A4BE-FD7F7EBABB44" Version="1.30.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="7b75e00f-ae8d-472e-9d0f-cbfe5e44017c" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>Haches & Dés</DisplayName>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue