mirror of
https://github.com/rejetto/hfs2.git
synced 2025-12-19 10:03:56 +01:00
fix: unicode support with {.exec|out.}
This commit is contained in:
parent
62c30c8de1
commit
a47541286a
22
utillib.pas
22
utillib.pas
@ -2220,7 +2220,7 @@ const
|
|||||||
var
|
var
|
||||||
sa : TSecurityAttributes;
|
sa : TSecurityAttributes;
|
||||||
ReadPipe,WritePipe : THandle;
|
ReadPipe,WritePipe : THandle;
|
||||||
start : TStartUpInfoA;
|
start : TStartUpInfoW;
|
||||||
ProcessInfo : TProcessInformation;
|
ProcessInfo : TProcessInformation;
|
||||||
Buffer : Pansichar;
|
Buffer : Pansichar;
|
||||||
TotalBytesRead,
|
TotalBytesRead,
|
||||||
@ -2251,7 +2251,7 @@ else
|
|||||||
timeout:=now()+timeout/SECONDS;
|
timeout:=now()+timeout/SECONDS;
|
||||||
// Create a Console Child Process with redirected input and output
|
// Create a Console Child Process with redirected input and output
|
||||||
try
|
try
|
||||||
if CreateProcessA(nil, PansiChar(ansistring(DosApp)), @sa, @sa, true, CREATE_NO_WINDOW or NORMAL_PRIORITY_CLASS, nil, nil, start, ProcessInfo) then
|
if CreateProcess(nil, PChar(dosApp), @sa, @sa, true, CREATE_NO_WINDOW or NORMAL_PRIORITY_CLASS, nil, nil, start, ProcessInfo) then
|
||||||
repeat
|
repeat
|
||||||
result:=TRUE;
|
result:=TRUE;
|
||||||
// wait for end of child process
|
// wait for end of child process
|
||||||
@ -2261,16 +2261,22 @@ try
|
|||||||
// so that the pipe is not blocked by an overflow. New information
|
// so that the pipe is not blocked by an overflow. New information
|
||||||
// can be written from the console app to the pipe only if there is
|
// can be written from the console app to the pipe only if there is
|
||||||
// enough buffer space.
|
// enough buffer space.
|
||||||
if not PeekNamedPipe(ReadPipe, @Buffer[TotalBytesRead], ReadBuffer,
|
if not PeekNamedPipe(ReadPipe, @Buffer[TotalBytesRead], ReadBuffer, @BytesRead, @TotalBytesAvail, @BytesLeftThisMessage )
|
||||||
@BytesRead, @TotalBytesAvail, @BytesLeftThisMessage ) then
|
or (BytesRead > 0) and not ReadFile(ReadPipe, Buffer[TotalBytesRead], BytesRead, BytesRead, nil ) then
|
||||||
break
|
break;
|
||||||
else if BytesRead > 0 then
|
|
||||||
ReadFile(ReadPipe, Buffer[TotalBytesRead], BytesRead, BytesRead, nil );
|
|
||||||
inc(TotalBytesRead, BytesRead);
|
inc(TotalBytesRead, BytesRead);
|
||||||
until (Apprunning <> WAIT_TIMEOUT) or (now() >= timeout);
|
until (Apprunning <> WAIT_TIMEOUT) or (now() >= timeout);
|
||||||
|
if IsTextUnicode(Buffer, TotalBytesRead, NIL) then
|
||||||
|
begin
|
||||||
|
Pchar(@Buffer[TotalBytesRead])^:= #0;
|
||||||
|
output:=pchar(Buffer)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
Buffer[TotalBytesRead]:= #0;
|
Buffer[TotalBytesRead]:= #0;
|
||||||
OemToCharA(PansiChar(Buffer),Buffer);
|
OemToCharA(Buffer,Buffer);
|
||||||
output:=string(ansistrings.strPas(Buffer));
|
output:=string(ansistrings.strPas(Buffer));
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
GetExitCodeProcess(ProcessInfo.hProcess, exitcode);
|
GetExitCodeProcess(ProcessInfo.hProcess, exitcode);
|
||||||
TerminateProcess(ProcessInfo.hProcess, 0);
|
TerminateProcess(ProcessInfo.hProcess, 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user