[ALL] Move a couple things

This commit is contained in:
Matt Nadareski
2017-11-08 22:03:42 -08:00
parent 732eac65ce
commit 1aef18aa00
7 changed files with 4 additions and 78 deletions

View File

@@ -1,113 +0,0 @@
using System.Collections.Generic;
using SabreTools.Library.Data;
/// <summary>
/// http://www.rarlab.com/technote.htm#srvheaders
/// </summary>
namespace SabreTools.Library.Tools
{
public class CoreRarArchive
{
// SFX Module Information
public byte[] SFX;
// Standard Header Information
public uint HeaderCRC32;
public uint HeaderSize; // vint
public RarHeaderFlags HeaderFlags; // vint
public uint ExtraAreaSize; // vint
public RarArchiveFlags ArchiveFlags; // vint
public uint VolumeNumber; // vint
public byte[] ExtraArea;
// Encryption Header Information
public uint EncryptionHeaderCRC32;
public uint EncryptionHeaderSize; // vint
public RarHeaderFlags EncryptionHeaderFlags; // vint
public uint EncryptionVersion; // vint
public uint EncryptionFlags; // vint
public byte KDFCount;
public byte[] Salt = new byte[16];
public byte[] CheckValue = new byte[12];
// Locator Information
public uint LocatorSize; // vint
public uint LocatorFlags; // vint
public uint QuickOpenOffset; // vint
public uint RecoveryRecordOffset; // vint
// Entry Information
public List<CoreRarArchiveEntry> Entries = new List<CoreRarArchiveEntry>();
}
public class CoreRarArchiveEntry
{
// Standard Entry Information
public uint HeaderCRC32;
public uint HeaderSize; // vint
public RarHeaderType HeaderType; // vint
public RarHeaderFlags HeaderFlags; // vint
public uint ExtraAreaSize; // vint
public uint DataAreaSize; // vint
public RarFileFlags FileFlags; // vint
public uint UnpackedSize; // vint
public uint Attributes; // vint
public uint mtime;
public uint DataCRC32;
public uint CompressionInformation; // vint
public uint HostOS; // vint
public uint NameLength; // vint
public byte[] Name;
public byte[] DataArea;
// File Encryption Information
public uint EncryptionSize; // vint
public RarEncryptionFlags EncryptionFlags; // vint
public byte KDFCount;
public byte[] Salt = new byte[16];
public byte[] IV = new byte[16];
public byte[] CheckValue = new byte[12];
// File Hash Information
public uint HashSize; // vint
public uint HashType; // vint
public byte[] HashData = new byte[32];
// File Time Information
public uint TimeSize; // vint
public RarTimeFlags TimeFlags; // vint
public uint TimeMtime;
public ulong TimeMtime64;
public uint TimeCtime;
public ulong TimeCtime64;
public uint TimeLtime;
public ulong TimeLtime64;
// File Version Information
public uint VersionSize; // vint
public const uint VersionFlags = 0; // vint
public uint VersionNumber; // vint
// File System Redirection Record
public uint RedirectionSize; // vint
public RarRedirectionType RedirectionType; // vint
public uint RedirectionFlags; // vint
public uint RedirectionNameLength; // vint
public byte[] RedirectionName;
// Unix Owner Record
public uint UnixOwnerSize; // vint
public RarUnixOwnerRecordFlags UnixOwnerFlags; // vint
public uint UnixOwnerUserNameLength; // vint
public byte[] UnixOwnerUserName;
public uint UnixOwnerGroupNameLength; // vint
public byte[] UnixOwnerGroupName;
public uint UnixOwnerUserId; // vint
public uint UnixOwnerGroupId; // vint
// Service Data Information
public uint ServiceSize; // vint
public byte[] ServiceData;
}
}

View File

@@ -1,154 +0,0 @@
/*
Copyright (c) 2012-2015 Eugene Larchenko (spct@mail.ru)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.IO;
namespace OCRC
{
public class OptimizedCRC : IDisposable
{
private const uint kCrcPoly = 0xEDB88320;
private const uint kInitial = 0xFFFFFFFF;
private const int CRC_NUM_TABLES = 8;
private static readonly uint[] Table;
static OptimizedCRC()
{
unchecked
{
Table = new uint[256 * CRC_NUM_TABLES];
int i;
for (i = 0; i < 256; i++)
{
uint r = (uint)i;
for (int j = 0; j < 8; j++)
{
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
}
Table[i] = r;
}
for (; i < 256 * CRC_NUM_TABLES; i++)
{
uint r = Table[i - 256];
Table[i] = Table[r & 0xFF] ^ (r >> 8);
}
}
}
public uint UnsignedValue;
public OptimizedCRC()
{
Init();
}
/// <summary>
/// Reset CRC
/// </summary>
public void Init()
{
UnsignedValue = kInitial;
}
public int Value
{
get { return (int)~UnsignedValue; }
}
public void Update(byte[] data, int offset, int count)
{
new ArraySegment<byte>(data, offset, count); // check arguments
if (count == 0)
{
return;
}
var table = OptimizedCRC.Table;
uint crc = UnsignedValue;
for (; (offset & 7) != 0 && count != 0; count--)
{
crc = (crc >> 8) ^ table[(byte)crc ^ data[offset++]];
}
if (count >= 8)
{
/*
* Idea from 7-zip project sources (http://7-zip.org/sdk.html)
*/
int end = (count - 8) & ~7;
count -= end;
end += offset;
while (offset != end)
{
crc ^= (uint)(data[offset] + (data[offset + 1] << 8) + (data[offset + 2] << 16) + (data[offset + 3] << 24));
uint high = (uint)(data[offset + 4] + (data[offset + 5] << 8) + (data[offset + 6] << 16) + (data[offset + 7] << 24));
offset += 8;
crc = table[(byte)crc + 0x700]
^ table[(byte)(crc >>= 8) + 0x600]
^ table[(byte)(crc >>= 8) + 0x500]
^ table[/*(byte)*/(crc >> 8) + 0x400]
^ table[(byte)(high) + 0x300]
^ table[(byte)(high >>= 8) + 0x200]
^ table[(byte)(high >>= 8) + 0x100]
^ table[/*(byte)*/(high >> 8) + 0x000];
}
}
while (count-- != 0)
{
crc = (crc >> 8) ^ table[(byte)crc ^ data[offset++]];
}
UnsignedValue = crc;
}
static public int Compute(byte[] data, int offset, int count)
{
var crc = new OptimizedCRC();
crc.Update(data, offset, count);
return crc.Value;
}
static public int Compute(byte[] data)
{
return Compute(data, 0, data.Length);
}
static public int Compute(ArraySegment<byte> block)
{
return Compute(block.Array, block.Offset, block.Count);
}
public void Dispose()
{
UnsignedValue = 0;
}
}
}

View File

@@ -17,7 +17,6 @@ using MemoryStream = System.IO.MemoryStream;
using PathTooLongException = System.IO.PathTooLongException;
using Stream = System.IO.Stream;
#endif
using OCRC;
namespace ROMVault2.SupportedFiles.Zip
{

View File

@@ -8,7 +8,6 @@ using SabreTools.Library.Data;
using SabreTools.Library.Tools;
using Ionic.Zlib;
using OCRC;
namespace ROMVault2.SupportedFiles.Zip
{

View File

@@ -1,69 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
#if MONO
using System.IO;
#else
using Alphaleonis.Win32.Filesystem;
using IOException = System.IO.IOException;
using SearchOption = System.IO.SearchOption;
#endif
using SabreTools.Library.Data;
namespace SabreTools.Library.External
{
public class Traverse
{
/// Original version: Microsoft (example code), updated by edc
public void TraverseTreeParallelForEach(string root, Action<FileInfo> action)
{
List<string> dirs = new List<string>();
if (!Directory.Exists(root))
{
throw new ArgumentException();
}
dirs.Add(root);
List<string> subdirs = new List<string>();
while (dirs.Count > 0 || subdirs.Count > 0)
{
foreach (string dir in subdirs)
{
dirs.Add(dir);
}
subdirs.Clear();
foreach (string currentDir in dirs)
{
string[] subDirs = Directory.GetDirectories(currentDir);
lock (subdirs)
{
foreach (string str in subDirs)
{
subdirs.Add(str);
}
}
var dir = new DirectoryInfo(currentDir);
try
{
FileInfo[] files = dir.GetFiles("*.*", SearchOption.TopDirectoryOnly);
Parallel.ForEach(files, Globals.ParallelOptions, info =>
{
action(info);
});
}
catch { }
}
dirs.Clear();
}
}
}
}