1// PipedAppRunner.h 2 3#ifndef PIPED_APP_RUNNER_H 4#define PIPED_APP_RUNNER_H 5 6#include <stdio.h> 7 8#include <DataIO.h> 9#include <Locker.h> 10 11class PipedAppRunner { 12public: 13 PipedAppRunner(); 14 ~PipedAppRunner(); 15 16 status_t Run(const char *command, const char *args = NULL, 17 bool findCommand = true); 18 bool HasQuitted(); 19 void WaitFor(); 20 21 status_t GetOutput(BString *buffer); 22 ssize_t ReadOutput(void *buffer, size_t size); 23 ssize_t ReadOutputAt(off_t position, void *buffer, size_t size); 24 25private: 26 static int32 _ReaderEntry(void *data); 27 int32 _ReaderLoop(); 28 void _ClosePipe(); 29 30private: 31 BLocker fOutputLock; 32 FILE *fPipe; 33 BMallocIO fOutput; 34 thread_id fReader; 35}; 36 37#endif // PIPED_APP_RUNNER_H 38