- 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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -328,6 +329,37 @@ namespace FileConverter
|
|||||||
index++;
|
index++;
|
||||||
break;
|
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":
|
case "verbose":
|
||||||
{
|
{
|
||||||
this.verbose = true;
|
this.verbose = true;
|
||||||
|
@ -21,6 +21,8 @@ namespace FileConverterExtension
|
|||||||
[COMServerAssociation(AssociationType.AllFiles)]
|
[COMServerAssociation(AssociationType.AllFiles)]
|
||||||
public class FileConverterExtension : SharpContextMenu
|
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 PresetReference[] presetReferences = null;
|
||||||
private List<MenuEntry> menuEntries = new List<MenuEntry>();
|
private List<MenuEntry> menuEntries = new List<MenuEntry>();
|
||||||
|
|
||||||
@ -301,29 +303,80 @@ namespace FileConverterExtension
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(PathHelpers.FileConverterPath)
|
void BuildConversionPresetArgument(StringBuilder sb)
|
||||||
{
|
{
|
||||||
CreateNoWindow = false,
|
sb.Append("--conversion-preset ");
|
||||||
UseShellExecute = false,
|
sb.Append(" \"");
|
||||||
RedirectStandardOutput = false,
|
sb.Append(presetName);
|
||||||
};
|
sb.Append("\"");
|
||||||
|
}
|
||||||
|
|
||||||
// Build arguments string.
|
// Build arguments string.
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.Append("--conversion-preset ");
|
BuildConversionPresetArgument(stringBuilder);
|
||||||
stringBuilder.Append(" \"");
|
|
||||||
stringBuilder.Append(presetName);
|
|
||||||
stringBuilder.Append("\"");
|
|
||||||
|
|
||||||
|
string fileListPath = null;
|
||||||
foreach (var filePath in this.SelectedItemPaths)
|
foreach (var filePath in this.SelectedItemPaths)
|
||||||
{
|
{
|
||||||
stringBuilder.Append(" \"");
|
stringBuilder.Append(" \"");
|
||||||
stringBuilder.Append(filePath);
|
stringBuilder.Append(filePath);
|
||||||
stringBuilder.Append("\"");
|
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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
processStartInfo.Arguments = stringBuilder.ToString();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var processStartInfo = new ProcessStartInfo(PathHelpers.FileConverterPath)
|
||||||
|
{
|
||||||
|
CreateNoWindow = false,
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = false,
|
||||||
|
Arguments = stringBuilder.ToString(),
|
||||||
|
};
|
||||||
|
|
||||||
Process exeProcess = Process.Start(processStartInfo);
|
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: 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: 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).
|
- 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 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 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.
|
- Fixed: Issue where icons and images were blurry on high dpi device.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user