]> err.no Git - sope/blob - sope-core/NGStreams/NGTaskStream.m
fixed an id string
[sope] / sope-core / NGStreams / NGTaskStream.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "config.h"
24 #include "common.h"
25 #include "NGTaskStream.h"
26
27 @implementation NGTaskStream
28
29 - (id)initWithPath:(NSString *)_executable
30   arguments:(NSArray *)_args
31   environment:(NSDictionary *)_env
32 {
33   return nil;
34 }
35
36 - (void)dealloc {
37   [super dealloc];
38 }
39
40 /* state */
41
42 - (BOOL)isOpen {
43   return [self->task isRunning];
44 }
45
46 /* primitives */
47
48 - (unsigned)readBytes:(void *)_buf count:(unsigned)_len {
49   return NGStreamError;
50 }
51 - (unsigned)writeBytes:(const void *)_buf count:(unsigned)_len {
52   return NGStreamError;
53 }
54
55 - (BOOL)close {
56   if (![self isOpen]) {
57     NSLog(@"tried to close already closed stream %@", self);
58     return NO;
59   }
60   [self->task terminate];
61   return YES;
62 }
63
64 - (NGStreamMode)mode {
65   return NGStreamMode_readWrite;
66 }
67 - (BOOL)isRootStream {
68   return YES;
69 }
70
71 /* marking */
72
73 - (BOOL)mark {
74   NSLog(@"WARNING: called mark on a stream which doesn't support marking !");
75   return NO;
76 }
77 - (BOOL)rewind {
78   [[[NGStreamException alloc] initWithStream:self
79                               reason:@"marking not supported"] raise];
80   return NO;
81 }
82 - (BOOL)markSupported {
83   return -1;
84 }
85
86 /* description */
87
88 - (NSString *)description {
89   return [NSString stringWithFormat:
90                      @"<%@[0x%08X] task=%@ mode=%@>",
91                      NSStringFromClass([self class]), (unsigned)self,
92                      self->task,
93                      [self modeDescription]];
94 }
95
96 @end /* NGTaskStream */