2019-12-04 15:42:30 -08:00
|
|
|
|
/******************************************************
|
|
|
|
|
|
* ROMVault3 is written by Gordon J. *
|
|
|
|
|
|
* Contact gordon@romvault.com *
|
2021-01-29 17:18:28 -08:00
|
|
|
|
* Copyright 2020 *
|
2019-12-04 15:42:30 -08:00
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Runtime.ConstrainedExecution;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Runtime.Versioning;
|
|
|
|
|
|
using System.Security.Permissions;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using Microsoft.Win32.SafeHandles;
|
|
|
|
|
|
|
|
|
|
|
|
namespace RVIO
|
|
|
|
|
|
{
|
|
|
|
|
|
internal static class Win32Native
|
|
|
|
|
|
{
|
|
|
|
|
|
private const string KERNEL32 = "kernel32.dll";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
|
|
|
|
|
|
[ResourceExposure(ResourceScope.Machine)]
|
|
|
|
|
|
internal static extern int GetShortPathName(
|
|
|
|
|
|
[MarshalAs(UnmanagedType.LPTStr)] string path,
|
|
|
|
|
|
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
|
|
|
|
|
|
int shortPathLength
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-01-29 17:18:28 -08:00
|
|
|
|
|
|
|
|
|
|
public static class FileParamConvert
|
2019-12-04 15:42:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
private const long TicksPerMillisecond = 10000;
|
2020-04-03 13:19:21 -07:00
|
|
|
|
private const long TicksPerSecond = TicksPerMillisecond * 1000;
|
|
|
|
|
|
private const long TicksPerMinute = TicksPerSecond * 60;
|
|
|
|
|
|
private const long TicksPerHour = TicksPerMinute * 60;
|
|
|
|
|
|
private const long TicksPerDay = TicksPerHour * 24;
|
2019-12-04 15:42:30 -08:00
|
|
|
|
|
2021-01-29 17:18:28 -08:00
|
|
|
|
// Number of days in a non-leap year
|
2019-12-04 15:42:30 -08:00
|
|
|
|
private const int DaysPerYear = 365;
|
2021-01-29 17:18:28 -08:00
|
|
|
|
// Number of days in 4 years
|
2020-04-03 13:19:21 -07:00
|
|
|
|
private const int DaysPer4Years = DaysPerYear * 4 + 1;
|
2019-12-04 15:42:30 -08:00
|
|
|
|
// Number of days in 100 years
|
2020-04-03 13:19:21 -07:00
|
|
|
|
private const int DaysPer100Years = DaysPer4Years * 25 - 1;
|
2019-12-04 15:42:30 -08:00
|
|
|
|
// Number of days in 400 years
|
2020-04-03 13:19:21 -07:00
|
|
|
|
private const int DaysPer400Years = DaysPer100Years * 4 + 1;
|
2019-12-04 15:42:30 -08:00
|
|
|
|
|
2021-01-29 17:18:28 -08:00
|
|
|
|
// Number of days from 1/1/0001 to 12/31/1600
|
2020-04-03 13:19:21 -07:00
|
|
|
|
private const int DaysTo1601 = DaysPer400Years * 4;
|
|
|
|
|
|
public const long FileTimeOffset = DaysTo1601 * TicksPerDay;
|
2019-12-04 15:42:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|