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
00018 inline void open( const char* command, const char* mode ) {
00019 stream = popen( command, mode );
00020 }
00021
00022
00023
00024
00025
00026 inline int create( int file_descriptor[2] ) {
00027 return pipe( file_descriptor[2] );
00028 }
00029
00030
00031 inline void error( const char* msg ) {
00032 perror( msg );
00033 }
00034
00035
00036
00037 inline int close() {
00038 return pclose( stream );
00039 }
00040
00041 public:
00042 FILE* stream;
00043 };
00044
00045 #endif