+ contrib/hbpipeio/hbpipeio.hbc
+ contrib/hbpipeio/hbpipeio.hbp
+ contrib/hbpipeio/hbpipeio.hbx
+ contrib/hbpipeio/pipeio.c
+ contrib/hbpipeio/tests/hbmk.hbm
+ contrib/hbpipeio/tests/test.prg
+ added PIPEIO new Harbour FILE IO redirector
As file name prefix "PIPE:" and "|" can be used.
This redirector executes command passed as file name with its
stdin and stdout handles redirected to Harbour FILE handle, i.e.:
REQUEST HB_PIPEIO
pFile := hb_vfOpen( "PIPE:ls -la", 0 )
? upper( hb_vfReadLen( pFile, 10000 ) )
hb_vfClose( pFile )
PIPEIO has also two new PRG functions:
hb_vfFromPipes( [<hReads>], [<hWrite>], [<hProcess>], ;
[<nTimeout>] -> <pHandle> | NIL
hb_vfOpenProcess( <cCommand>, [<nMode>=FO_READ], ;
[<nTimeout>], [<lDetach>] ) -> <pHandle> | NIL
The first one can be used to create Harbour file redirector for
process created by hb_processOpen(), i.e.:
hProcess := hb_processOpen( cCommand, @hStdIn, @hStdOut )
pFile := hb_vfFromPipes( hStdOut, hStdIn, hProcess, 5000 )
The second one can be used directly:
pFile := hb_vfFromPipes( cCommand, FO_READWRITE, 5000 )
Usually process which reads from its stdin works until its input
stream is closed by other process. If user wants to close input
stream for command redirected to Harbour PIPE FILE IO then he can
execute:
hb_vfConfig( pFile, HB_VF_SHUTDOWN, FO_WRITE )
Look at the test code for real life example. It opens 'gzip' command
in FO_READWRITE mode, sends data to gzip, reads gzip output and finally
decompress it using hb_ZUncompress() to check if result is equal to
initial data.
4 lines
85 B
Plaintext
4 lines
85 B
Plaintext
description=I/O driver for pipe streams
|
|
|
|
libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}
|