62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
using BS.SharedLauncher.Utils;
|
|
using BS.SharedLauncher.Enums;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Security.Cryptography;
|
|
using BS.SharedLauncher.Update;
|
|
|
|
namespace BS.SharedLauncher.Update
|
|
{
|
|
public class PlanerFile
|
|
{
|
|
public string Name { get; set; }
|
|
public string Extension { get; set; }
|
|
public string AbsolutePath { get; set; }
|
|
public string RelativePath { get; set; }
|
|
public PlanerUpdateSource Source { get; set; }
|
|
//public Version FileVersion { get; set; }
|
|
|
|
//public byte[] FileData { get; set; }
|
|
public string Checksum { get; set; }
|
|
|
|
public PlanerFile(FileInfo fileInfo, string relativeTo, PlanerUpdateSource source)
|
|
{
|
|
Name = fileInfo.Name;
|
|
Extension = fileInfo.Extension;
|
|
AbsolutePath = fileInfo.FullName;
|
|
RelativePath = PathUtils.MakeRelativePath(relativeTo, fileInfo.FullName);
|
|
Source = source;
|
|
}
|
|
|
|
//public static PlanerFile Init(FileInfo fileInfo, string relativeTo, PlanerUpdateSource source)
|
|
//{
|
|
// var res = new PlanerFile()
|
|
// {
|
|
// FileSystemName = fileInfo.Name,
|
|
// FileSystemExtension = fileInfo.Extension,
|
|
// FileSystemAbsolutePath = fileInfo.FullName,
|
|
// FileSystemRelativePath = PathUtils.MakeRelativePath(relativeTo, fileInfo.FullName),
|
|
// FileSystemSource = source
|
|
// };
|
|
|
|
// return res;
|
|
//}
|
|
|
|
public void Load()
|
|
{
|
|
//FileData = File.ReadAllBytes(AbsolutePath);
|
|
using (var md5 = MD5.Create())
|
|
{
|
|
using (var stream = File.OpenRead(AbsolutePath))
|
|
{
|
|
Checksum = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLowerInvariant();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|