]> err.no Git - sope/blob - sope-core/NGStreams/NGTerminalSupport.m
added a new mkdirs like method to NSFileManager
[sope] / sope-core / NGStreams / NGTerminalSupport.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 "NGTerminalSupport.h"
24 #include "NGFileStream.h"
25 #include "NGFilterStream.h"
26 #include "NGCTextStream.h"
27 #include "NGDescriptorFunctions.h"
28
29 @implementation NGStream(NGTerminalSupport)
30
31 - (BOOL)isAssociatedWithTerminalDevice {
32   return NO;
33 }
34
35 - (NSString *)nameOfAssociatedTerminalDevice {
36   return nil;
37 }
38
39 @end
40
41 @implementation NGFileStream(NGTerminalSupport)
42
43 - (BOOL)isAssociatedWithTerminalDevice {
44 #if defined(WIN32)
45   return NO;
46 #else
47   return [self isOpen] ? NGDescriptorIsAtty(self->fd) : NO;
48 #endif
49 }
50
51 - (NSString *)nameOfAssociatedTerminalDevice {
52 #if defined(WIN32)
53   return nil;
54 #else
55   return [self isOpen] ? NGDescriptorGetTtyName(self->fd) : nil;
56 #endif
57 }
58
59 @end
60
61 @implementation NGFilterStream(NGTerminalSupport)
62
63 - (BOOL)isAssociatedWithTerminalDevice {
64   id src = [self source];
65   
66   return [src respondsToSelector:_cmd]
67     ? [src isAssociatedWithTerminalDevice]
68     : NO;
69 }
70
71 - (NSString *)nameOfAssociatedTerminalDevice {
72   id src = [self source];
73   
74   return [src respondsToSelector:_cmd]
75     ? [src nameOfAssociatedTerminalDevice]
76     : NO;
77 }
78
79 @end
80
81 @implementation NGTextStream(NGTerminalSupport)
82
83 - (BOOL)isAssociatedWithTerminalDevice {
84   return NO;
85 }
86 - (NSString *)nameOfAssociatedTerminalDevice {
87   return nil;
88 }
89
90 @end
91
92 @implementation NGCTextStream(NGTerminalSupport)
93
94 - (BOOL)isAssociatedWithTerminalDevice {
95   id src = [self source];
96   
97   return [src respondsToSelector:_cmd]
98     ? [src isAssociatedWithTerminalDevice]
99     : NO;
100 }
101
102 - (NSString *)nameOfAssociatedTerminalDevice {
103   id src = [self source];
104   
105   return [src respondsToSelector:_cmd]
106     ? [src nameOfAssociatedTerminalDevice]
107     : NO;
108 }
109
110 @end
111
112 void __link_NGStreams_NGTerminalSupport(void) {
113   __link_NGStreams_NGTerminalSupport();
114 }