mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Internal Fixes, etc. (#20)
* Start removing mixed usages
* Check for directories before opening
* Fix writing
* Kinda fix rebuild
* One more try
* Better internal handling
* Slighty fix a couple more things
* Update RVWorld Compress code to db7d750bba
* Fix build
Co-authored-by: Matt Nadareski <mnadareski@mparticle.com>
This commit is contained in:
14
SabreTools.Library/External/RVIO/RVIO.cs
vendored
14
SabreTools.Library/External/RVIO/RVIO.cs
vendored
@@ -282,7 +282,7 @@ namespace RVIO
|
||||
if (!Win32Native.MoveFile(fullsourceDirName, fulldestDirName))
|
||||
{
|
||||
int hr = Marshal.GetLastWin32Error();
|
||||
if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // Source dir not found
|
||||
if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // Source dir not found
|
||||
{
|
||||
throw new Exception("ERROR_PATH_NOT_FOUND " + fullsourceDirName);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ namespace RVIO
|
||||
bool r = Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite);
|
||||
if (!r)
|
||||
{
|
||||
// Save Win32 error because subsequent checks will overwrite this HRESULT.
|
||||
// Save Win32 error because subsequent checks will overwrite this HRESULT.
|
||||
int errorCode = Marshal.GetLastWin32Error();
|
||||
string fileName = destFileName;
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace RVIO
|
||||
if (errorCode != Win32Native.ERROR_FILE_EXISTS)
|
||||
{
|
||||
// For a number of error codes (sharing violation, path
|
||||
// not found, etc) we don't know if the problem was with
|
||||
// not found, etc) we don't know if the problem was with
|
||||
// the source or dest file. Try reading the source file.
|
||||
using (SafeFileHandle handle = Win32Native.UnsafeCreateFile(fullSourceFileName, FileStream.GENERIC_READ, FileShare.Read, null, FileMode.Open, 0, IntPtr.Zero))
|
||||
{
|
||||
@@ -416,7 +416,7 @@ namespace RVIO
|
||||
throw new Exception(GetErrorCode(hr), new Exception("ERROR_MOVING_FILE. (" + fullSourceFileName + " to " + fullDestFileName + ")"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void Delete(string path)
|
||||
{
|
||||
if (unix.IsUnix)
|
||||
@@ -443,6 +443,8 @@ namespace RVIO
|
||||
{
|
||||
case 5: return "ERROR_ACCESS_DENIED: Access is denied.";
|
||||
case 32: return "ERROR_FILE_IN_USE: The file is in use by another process.";
|
||||
case 39: return "ERROR_HANDLE_DISK_FULL: The disk is full.";
|
||||
case 112: return "ERROR_DISK_FULL: There is not enough space on the disk.";
|
||||
case 123: return "ERROR_INVALID_NAME: The filename, directory name, or volume label syntax is incorrect.";
|
||||
case 183: return "ERROR_ALREADY_EXISTS: Cannot create a file when that file already exists.";
|
||||
}
|
||||
@@ -464,7 +466,7 @@ namespace RVIO
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string fullPath = NameFix.AddLongPathPrefix(path);
|
||||
return Win32Native.SetFileAttributes(fullPath, (int)fileAttributes);
|
||||
}
|
||||
@@ -781,4 +783,4 @@ namespace RVIO
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
SabreTools.Library/External/RVIO/Win32Native.cs
vendored
32
SabreTools.Library/External/RVIO/Win32Native.cs
vendored
@@ -140,39 +140,39 @@ namespace RVIO
|
||||
internal static class Convert
|
||||
{
|
||||
private const long TicksPerMillisecond = 10000;
|
||||
private const long TicksPerSecond = TicksPerMillisecond*1000;
|
||||
private const long TicksPerMinute = TicksPerSecond*60;
|
||||
private const long TicksPerHour = TicksPerMinute*60;
|
||||
private const long TicksPerDay = TicksPerHour*24;
|
||||
private const long TicksPerSecond = TicksPerMillisecond * 1000;
|
||||
private const long TicksPerMinute = TicksPerSecond * 60;
|
||||
private const long TicksPerHour = TicksPerMinute * 60;
|
||||
private const long TicksPerDay = TicksPerHour * 24;
|
||||
|
||||
// Number of days in a non-leap year
|
||||
// Number of days in a non-leap year
|
||||
private const int DaysPerYear = 365;
|
||||
// Number of days in 4 years
|
||||
private const int DaysPer4Years = DaysPerYear*4 + 1;
|
||||
// Number of days in 4 years
|
||||
private const int DaysPer4Years = DaysPerYear * 4 + 1;
|
||||
// Number of days in 100 years
|
||||
private const int DaysPer100Years = DaysPer4Years*25 - 1;
|
||||
private const int DaysPer100Years = DaysPer4Years * 25 - 1;
|
||||
// Number of days in 400 years
|
||||
private const int DaysPer400Years = DaysPer100Years*4 + 1;
|
||||
private const int DaysPer400Years = DaysPer100Years * 4 + 1;
|
||||
|
||||
// Number of days from 1/1/0001 to 12/31/1600
|
||||
private const int DaysTo1601 = DaysPer400Years*4;
|
||||
public const long FileTimeOffset = DaysTo1601*TicksPerDay;
|
||||
// Number of days from 1/1/0001 to 12/31/1600
|
||||
private const int DaysTo1601 = DaysPer400Years * 4;
|
||||
public const long FileTimeOffset = DaysTo1601 * TicksPerDay;
|
||||
|
||||
|
||||
// Number of days from 1/1/0001 to 12/31/9999
|
||||
private const int DaysTo10000 = DaysPer400Years*25 - 366;
|
||||
private const int DaysTo10000 = DaysPer400Years * 25 - 366;
|
||||
private const long MinTicks = 0;
|
||||
private const long MaxTicks = DaysTo10000*TicksPerDay - 1;
|
||||
private const long MaxTicks = DaysTo10000 * TicksPerDay - 1;
|
||||
|
||||
|
||||
public static long Length(int high, int low)
|
||||
{
|
||||
return ((long) high << 32) | (low & 0xFFFFFFFFL);
|
||||
return ((long)high << 32) | (low & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
public static long Time(uint high, uint low)
|
||||
{
|
||||
return ((long) high << 32) | low;
|
||||
return ((long)high << 32) | low;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user