1997-09-01 21:59:51 +00:00
|
|
|
/* Implementation for NSPipe for GNUStep
|
|
|
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: 1997
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
1997-11-06 00:51:23 +00:00
|
|
|
#include <config.h>
|
1998-12-20 21:27:47 +00:00
|
|
|
#include <base/preface.h>
|
1997-09-01 21:59:51 +00:00
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
#include <Foundation/NSFileHandle.h>
|
|
|
|
|
1997-12-11 19:09:56 +00:00
|
|
|
#ifndef __WIN32__
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
@implementation NSPipe
|
|
|
|
|
|
|
|
// Allocating and Initializing a FileHandle Object
|
|
|
|
|
|
|
|
+ (id)pipe
|
|
|
|
{
|
|
|
|
return [[[self alloc] init] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
[readHandle release];
|
|
|
|
[writeHandle release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self)
|
|
|
|
{
|
|
|
|
int p[2];
|
|
|
|
|
|
|
|
if (pipe(p) == 0)
|
|
|
|
{
|
|
|
|
readHandle = [[NSFileHandle alloc] initWithFileDescriptor:p[0]];
|
|
|
|
writeHandle = [[NSFileHandle alloc] initWithFileDescriptor:p[1]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- fileHandleForReading
|
|
|
|
{
|
|
|
|
return readHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- fileHandleForWriting
|
|
|
|
{
|
|
|
|
return writeHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|