mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix drag and drop
This commit is contained in:
@@ -24,7 +24,7 @@ namespace SabreTools
|
|||||||
// Set local paths
|
// Set local paths
|
||||||
_7zPath = Environment.CurrentDirectory.Replace('/', '\\') + "\\7z" + (Environment.Is64BitOperatingSystem ? "\\x64" : "") + "\\";
|
_7zPath = Environment.CurrentDirectory.Replace('/', '\\') + "\\7z" + (Environment.Is64BitOperatingSystem ? "\\x64" : "") + "\\";
|
||||||
_tempDir = Environment.CurrentDirectory.Replace('/', '\\') + "\\temp" + DateTime.Now.ToString("yyyyMMddHHmmss") + "\\";
|
_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
|
// Set base arguments to be used
|
||||||
_baseExtract = "x -o\"" + _tempDir + "\"";
|
_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>>();
|
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
|
// 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))
|
foreach (string item in Directory.GetFiles(_basePath, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
// Create the temporary output directory
|
// Create the temporary output directory
|
||||||
@@ -150,6 +193,7 @@ namespace SabreTools
|
|||||||
Directory.Delete(_tempDir, true);
|
Directory.Delete(_tempDir, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Order the roms by name of parent, then name of rom
|
// 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)
|
roms.Sort(delegate (Tuple<string, string, long, string, string, string> A, Tuple<string, string, long, string, string, string> B)
|
||||||
|
|||||||
Reference in New Issue
Block a user