// NibSaver.m
// By Charles G. Fleming, Educational Computing Services, Allegheny College.
// Copyright 1993, Allegheny College.
// You may freely copy, distribute and reuse this code. 
// Allegheny College and the author disclaim any warranty of any kind, 
// expressed or implied, as to its fitness for any particular use.

#import "NibSaver.h"

@implementation NibSaver

- init
{
	dataStream = NXOpenMemory(NULL, 0, NX_READWRITE);
	return self;
}
	
- (BOOL)readDataFromStream:(NXStream*)stream
{
	NXGetMemoryBuffer(stream, &dataBuffer, &length, &maxLength);
	NXWrite(dataStream, dataBuffer, length);
	NXSeek(dataStream, 0, NX_FROMSTART);
	return YES;
}

- (BOOL)writeDataToStream:(NXStream*)stream
{
	NXGetMemoryBuffer(dataStream, &dataBuffer, &length, &maxLength);
	NXWrite(stream, dataBuffer, length);
	return YES;
}

- freeStream
{
	NXCloseMemory(dataStream, NX_FREEBUFFER);
	return self;
}	
@end
