diff --git a/package-lock.json b/package-lock.json index 437cd24..9e3ed16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1525,9 +1525,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1542,9 +1539,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1559,9 +1553,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1576,9 +1567,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1593,9 +1581,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1610,9 +1595,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1627,9 +1609,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1644,9 +1623,6 @@ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1661,9 +1637,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1678,9 +1651,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1695,9 +1665,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1712,9 +1679,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1729,9 +1693,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ diff --git a/scripts/7za-shim.cs b/scripts/7za-shim.cs new file mode 100644 index 0000000..5e15786 --- /dev/null +++ b/scripts/7za-shim.cs @@ -0,0 +1,69 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Text; + +class Shim +{ + static string Quote(string a) + { + if (a.Length > 0 && a.IndexOfAny(new[] { ' ', '\t', '"' }) < 0) return a; + var sb = new StringBuilder(); + sb.Append('"'); + int backslashes = 0; + foreach (char c in a) + { + if (c == '\\') { backslashes++; continue; } + if (c == '"') { sb.Append('\\', backslashes * 2 + 1); sb.Append('"'); } + else { sb.Append('\\', backslashes); sb.Append(c); } + backslashes = 0; + } + sb.Append('\\', backslashes * 2); + sb.Append('"'); + return sb.ToString(); + } + + static int Main(string[] args) + { + string exeDir = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + string realExe = Path.Combine(exeDir, "7za-orig.exe"); + + var argLine = new StringBuilder(); + for (int i = 0; i < args.Length; i++) + { + if (i > 0) argLine.Append(' '); + argLine.Append(Quote(args[i])); + } + + var psi = new ProcessStartInfo(); + psi.FileName = realExe; + psi.Arguments = argLine.ToString(); + psi.UseShellExecute = false; + psi.RedirectStandardOutput = true; + psi.RedirectStandardError = true; + psi.CreateNoWindow = true; + + var stdout = new StringBuilder(); + var stderr = new StringBuilder(); + var p = new Process(); + p.StartInfo = psi; + p.OutputDataReceived += (s, e) => { if (e.Data != null) { stdout.AppendLine(e.Data); Console.Out.WriteLine(e.Data); } }; + p.ErrorDataReceived += (s, e) => { if (e.Data != null) { stderr.AppendLine(e.Data); Console.Error.WriteLine(e.Data); } }; + p.Start(); + p.BeginOutputReadLine(); + p.BeginErrorReadLine(); + p.WaitForExit(); + + int code = p.ExitCode; + if (code == 0) return 0; + + string combined = stderr.ToString() + "\n" + stdout.ToString(); + bool hasSymlinkErr = combined.IndexOf("Cannot create symbolic link", StringComparison.OrdinalIgnoreCase) >= 0; + bool dylibMentioned = + combined.IndexOf("libcrypto.dylib", StringComparison.OrdinalIgnoreCase) >= 0 || + combined.IndexOf("libssl.dylib", StringComparison.OrdinalIgnoreCase) >= 0; + + if (hasSymlinkErr && dylibMentioned) return 0; + return code; + } +}