- Fixed: Issue where there was a maximum number of files to convert at the same time depending on the length of file paths (github issue #86).
This commit is contained in:
parent
f50a43ac85
commit
0157fdfb60
@ -18,6 +18,7 @@ namespace FileConverter
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
@ -328,6 +329,37 @@ namespace FileConverter
|
||||
index++;
|
||||
break;
|
||||
|
||||
case "input-files":
|
||||
if (index >= args.Length - 1)
|
||||
{
|
||||
quitAfterStartup = true;
|
||||
quitExitCode = 0x02;
|
||||
Debug.LogError(quitExitCode, $"Invalid format.");
|
||||
break;
|
||||
}
|
||||
|
||||
string fileListPath = args[index + 1];
|
||||
try
|
||||
{
|
||||
using (FileStream file = File.OpenRead(fileListPath))
|
||||
using (StreamReader reader = new StreamReader(file))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
filePaths.Add(reader.ReadLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
quitAfterStartup = true;
|
||||
quitExitCode = 0x03;
|
||||
Debug.LogError(quitExitCode, $"Can't read input files list: {exception}");
|
||||
}
|
||||
|
||||
index++;
|
||||
break;
|
||||
|
||||
case "verbose":
|
||||
{
|
||||
this.verbose = true;
|
||||
|
@ -21,6 +21,8 @@ namespace FileConverterExtension
|
||||
[COMServerAssociation(AssociationType.AllFiles)]
|
||||
public class FileConverterExtension : SharpContextMenu
|
||||
{
|
||||
private const int MaximumProcessArgumentsLength = 8000; // https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
|
||||
|
||||
private PresetReference[] presetReferences = null;
|
||||
private List<MenuEntry> menuEntries = new List<MenuEntry>();
|
||||
|
||||
@ -301,29 +303,80 @@ namespace FileConverterExtension
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(PathHelpers.FileConverterPath)
|
||||
void BuildConversionPresetArgument(StringBuilder sb)
|
||||
{
|
||||
CreateNoWindow = false,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = false,
|
||||
};
|
||||
sb.Append("--conversion-preset ");
|
||||
sb.Append(" \"");
|
||||
sb.Append(presetName);
|
||||
sb.Append("\"");
|
||||
}
|
||||
|
||||
// Build arguments string.
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("--conversion-preset ");
|
||||
stringBuilder.Append(" \"");
|
||||
stringBuilder.Append(presetName);
|
||||
stringBuilder.Append("\"");
|
||||
|
||||
BuildConversionPresetArgument(stringBuilder);
|
||||
|
||||
string fileListPath = null;
|
||||
foreach (var filePath in this.SelectedItemPaths)
|
||||
{
|
||||
stringBuilder.Append(" \"");
|
||||
stringBuilder.Append(filePath);
|
||||
stringBuilder.Append("\"");
|
||||
|
||||
if (stringBuilder.Length >= MaximumProcessArgumentsLength)
|
||||
{
|
||||
// Alternative way of passing arguments to not overflow the command line.
|
||||
stringBuilder.Clear();
|
||||
BuildConversionPresetArgument(stringBuilder);
|
||||
|
||||
// Store list of file to convert in a file in Temp folder.
|
||||
fileListPath = Path.Combine(Path.GetTempPath(), "file-converter-input-list.txt");
|
||||
int index = 1;
|
||||
while (File.Exists(fileListPath))
|
||||
{
|
||||
fileListPath = Path.Combine(Path.GetTempPath(), $"file-converter-input-list-{index}.txt");
|
||||
index++;
|
||||
}
|
||||
|
||||
using (FileStream file = File.OpenWrite(fileListPath))
|
||||
using (StreamWriter writer = new StreamWriter(file))
|
||||
{
|
||||
foreach (var path in this.SelectedItemPaths)
|
||||
{
|
||||
writer.WriteLine(path);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.Append(" --input-files ");
|
||||
stringBuilder.Append(" \"");
|
||||
stringBuilder.Append(fileListPath);
|
||||
stringBuilder.Append("\"");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
processStartInfo.Arguments = stringBuilder.ToString();
|
||||
var processStartInfo = new ProcessStartInfo(PathHelpers.FileConverterPath)
|
||||
{
|
||||
CreateNoWindow = false,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = false,
|
||||
Arguments = stringBuilder.ToString(),
|
||||
};
|
||||
|
||||
Process exeProcess = Process.Start(processStartInfo);
|
||||
exeProcess.EnableRaisingEvents = true;
|
||||
exeProcess.Exited += (sender, args) =>
|
||||
{
|
||||
if (fileListPath != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(fileListPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
- Change: Replace Pledgie donation button by Paypal donation button since Pledgie does not exist anymore.
|
||||
- Change: Correction of spell mistakes in the french translation (thanks to Sylvain Pollet-Villard).
|
||||
- Change: Change output files timestamp to match original file (github issue #33) (thanks to Diego López Bugna).
|
||||
- Fixed: Issue where there was a maximum number of files to convert at the same time depending on the length of file paths (github issue #86).
|
||||
- Fixed: Issue where File Converter version upgrade download was not working due to an issue with https encryption.
|
||||
- Fixed: Issue where output video was not working correclty on some video players like Quick time (github issue #34) (thanks to Diego López Bugna).
|
||||
- Fixed: Issue where icons and images were blurry on high dpi device.
|
||||
|
Loading…
x
Reference in New Issue
Block a user