Skip to content

Commit 4d17455

Browse files
committed
PowerShell script now working with io.popen
1 parent 4652c40 commit 4d17455

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/library/client.lua

-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ function client.execute(command)
232232
return process.execute(command)
233233
end
234234
end
235-
print("popen " .. command)
236235
local handle = io.popen(command)
237236
if not handle then return nil end
238237
local retval = handle:read("*a")

src/library/ziputils.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,14 @@ function ziputils.calc_gunzip_command(archive_path)
108108
return "gunzip -c " .. archive_path
109109
else
110110
local command = table.concat({
111-
"$fs = New-Object IO.Filestream('%s',([IO.FileMode]::Open),([IO.FileAccess]::Read),([IO.FileShare]::Read))",
112-
"$gz = New-Object IO.Compression.GzipStream($fs,[IO.Compression.CompressionMode]::Decompress)",
113-
"$sr = New-Object IO.StreamReader($gz)",
114-
"while (-not $sr.EndOfStream) { Write-Output $sr.ReadLine() }",
115-
"$sr.Close()"
111+
"$fs = New-Object IO.FileStream('%s', [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::Read)",
112+
"$gz = New-Object IO.Compression.GzipStream($fs, [IO.Compression.CompressionMode]::Decompress)",
113+
"$buffer = New-Object byte[] 4096", -- Define a buffer size (e.g., 4096 bytes)
114+
"while (($read = $gz.Read($buffer, 0, $buffer.Length)) -gt 0) {",
115+
" [Console]::OpenStandardOutput().Write($buffer, 0, $read)",
116+
"}",
117+
"$gz.Close()",
118+
"$fs.Close()"
116119
}, "; ")
117120
command = string.format(command, archive_path)
118121
return string.format("powershell -c \"%s\"", command)

0 commit comments

Comments
 (0)