mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-01-21 01:13:33 +08:00
Add option to append file extension in ExtractToDirectory
Introduced an 'appendExtension' parameter to ExtractToDirectory, allowing guessed file extensions to be appended to extracted resource filenames. This enhances usability by making extracted files easier to identify by type.
This commit is contained in:
@@ -33,7 +33,8 @@ public static class PakExtractor
|
||||
/// </summary>
|
||||
/// <param name="fileName">The path to the .pak file to extract.</param>
|
||||
/// <param name="outputDirectory">The directory where extracted resource files will be saved.</param>
|
||||
public static void ExtractToDirectory(string fileName, string outputDirectory)
|
||||
/// <param name="appendExtension">If true, append guessed file extension to the filename (e.g., "000000001.png").</param>
|
||||
public static void ExtractToDirectory(string fileName, string outputDirectory, bool appendExtension = true)
|
||||
{
|
||||
using var stream = File.OpenRead(fileName);
|
||||
using var br = new BinaryReader(stream);
|
||||
@@ -78,6 +79,11 @@ public static class PakExtractor
|
||||
read += n;
|
||||
}
|
||||
string resourceName = entries[i].ResourceId.ToString("D9");
|
||||
if (appendExtension)
|
||||
{
|
||||
string ext = GuessFileExtension(buffer, length);
|
||||
resourceName += ext;
|
||||
}
|
||||
using var file = File.Create(Path.Combine(outputDirectory, resourceName));
|
||||
file.Write(buffer, 0, length);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public sealed partial class Plugin
|
||||
// Chromium resource package file v5 extraction
|
||||
await Task.Run(() =>
|
||||
{
|
||||
PakExtractor.ExtractToDirectory(_path, dialog.FileName);
|
||||
PakExtractor.ExtractToDirectory(_path, dialog.FileName, appendExtension: true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user