Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/QNX4/Pipe.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__QNX__Pipe_HPP__
00002 #define __J2K__QNX__Pipe_HPP__
00003 
00004 #include <j2k/Fred/Basic.hpp>
00005 #include <unistd.h>
00006 
00007 class Pipe {
00008 public:
00009   Pipe() : stream( NULL ) { }
00010 
00011   virtual Pipe() {
00012     if ( stream != NULL ) {
00013       close();
00014     }
00015   }
00016 
00017   // Execute a command, creating a pipe to it.
00018   inline void open( const char* command, const char* mode ) {
00019     stream = popen( command, mode );
00020   }
00021 
00022   // Creates a pipe, unnamed FIFO, and places a file descriptor
00023   // for the read end of the pipe in file_descriptor[0],
00024   // and for the write in file_descriptor[1]
00025 
00026   inline int create( int file_descriptor[2] ) {
00027     return pipe( file_descriptor[2] );
00028   }
00029 
00030   // Print, in stderr, the msg with the value of errno
00031   inline void error( const char* msg ) {
00032     perror( msg );
00033   }
00034 
00035   // Close the pipe associated with stream.
00036   // Waits for the subprocess created by popen() to terminate.
00037   inline int close() {
00038     return pclose( stream );
00039   }
00040 
00041 public:
00042   FILE* stream;
00043 };
00044 
00045 #endif

Generated on Sun Oct 14 18:46:42 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001