Fix drag and drop

This commit is contained in:
Matt Nadareski
2016-04-11 17:32:32 -07:00
parent 045cfeb92f
commit fa1a39197a

View File

@@ -24,7 +24,7 @@ namespace SabreTools
// Set local paths
_7zPath = Environment.CurrentDirectory.Replace('/', '\\') + "\\7z" + (Environment.Is64BitOperatingSystem ? "\\x64" : "") + "\\";
_tempDir = Environment.CurrentDirectory.Replace('/', '\\') + "\\temp" + DateTime.Now.ToString("yyyyMMddHHmmss") + "\\";
_basePath = (args.Length == 0 ? Environment.CurrentDirectory : args[0]).Replace('/', '\\') + "\\";
_basePath = (args.Length == 0 ? Environment.CurrentDirectory + "\\" : (File.Exists(args[0]) ? args[0] : args[0] + "\\").Replace('/', '\\'));
// Set base arguments to be used
_baseExtract = "x -o\"" + _tempDir + "\"";
@@ -42,6 +42,49 @@ namespace SabreTools
List<Tuple<string, string, long, string, string, string>> roms = new List<Tuple<string, string, long, string, string, string>>();
// This is where the main loop would go
if (File.Exists(_basePath))
{
// Get a list of files including size and hashes
Crc32 crc = new Crc32();
MD5 md5 = MD5.Create();
SHA1 sha1 = SHA1.Create();
string fileCRC = String.Empty;
string fileMD5 = String.Empty;
string fileSHA1 = String.Empty;
try
{
using (FileStream fs = File.Open(_basePath, FileMode.Open))
{
foreach (byte b in crc.ComputeHash(fs))
{
fileCRC += b.ToString("x2").ToLower();
}
}
using (FileStream fs = File.Open(_basePath, FileMode.Open))
{
fileMD5 = BitConverter.ToString(md5.ComputeHash(fs)).Replace("-", "");
}
using (FileStream fs = File.Open(_basePath, FileMode.Open))
{
fileSHA1 = BitConverter.ToString(sha1.ComputeHash(fs)).Replace("-", "");
}
roms.Add(new Tuple<string, string, long, string, string, string>(
"Default",
_basePath,
(new FileInfo(_basePath)).Length,
fileCRC,
fileMD5,
fileSHA1));
Console.WriteLine("File parsed: " + _basePath.Remove(0, _basePath.Length));
}
catch (IOException) { }
}
else
{
foreach (string item in Directory.GetFiles(_basePath, "*", SearchOption.AllDirectories))
{
// Create the temporary output directory
@@ -150,6 +193,7 @@ namespace SabreTools
Directory.Delete(_tempDir, true);
}
}
}
// Order the roms by name of parent, then name of rom
roms.Sort(delegate (Tuple<string, string, long, string, string, string> A, Tuple<string, string, long, string, string, string> B)