1997-09-01 21:59:51 +00:00
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
|
|
|
#include <Foundation/NSFileHandle.h>
|
2005-02-23 16:05:09 +00:00
|
|
|
#include <Foundation/NSManager.h>
|
1997-09-01 21:59:51 +00:00
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
#include <Foundation/NSString.h>
|
2005-02-23 16:05:09 +00:00
|
|
|
#include <Foundation/NSURL.h>
|
2002-01-03 20:39:12 +00:00
|
|
|
#include <assert.h>
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
id pool;
|
|
|
|
id src;
|
|
|
|
id dst;
|
|
|
|
id d0;
|
|
|
|
id d1;
|
|
|
|
|
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
src = [[NSFileHandle fileHandleForReadingAtPath:@"nsfilehandle.m"] retain];
|
|
|
|
assert(src != nil);
|
|
|
|
dst = [[NSFileHandle fileHandleForWritingAtPath:@"nsfilehandle.dat"] retain];
|
|
|
|
if (dst == nil)
|
|
|
|
{
|
|
|
|
creat("nsfilehandle.dat", 0644);
|
|
|
|
dst = [[NSFileHandle fileHandleForWritingAtPath:@"nsfilehandle.dat"] retain];
|
|
|
|
}
|
|
|
|
assert(dst != nil);
|
|
|
|
|
|
|
|
d0 = [[src readDataToEndOfFile] retain];
|
2005-02-23 16:05:09 +00:00
|
|
|
[(NSFileHandle*)dst writeData: d0];
|
1997-09-01 21:59:51 +00:00
|
|
|
[src release];
|
|
|
|
[dst release];
|
|
|
|
[pool release];
|
|
|
|
|
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
src = [[NSFileHandle fileHandleForReadingAtPath:@"nsfilehandle.dat"] retain];
|
|
|
|
d1 = [[src readDataToEndOfFile] retain];
|
|
|
|
[src release];
|
|
|
|
[pool release];
|
|
|
|
|
|
|
|
unlink("nsfilehandle.dat");
|
|
|
|
|
|
|
|
if ([d0 isEqual:d1])
|
|
|
|
printf("Test passed (length:%d)\n", [d1 length]);
|
|
|
|
else
|
|
|
|
printf("Test failed\n");
|
|
|
|
|
2005-02-23 16:05:09 +00:00
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
src = [NSURL URLWithString: @"http://www.w3.org/index.html"];
|
|
|
|
d0 = [src resourceDataUsingCache: NO];
|
|
|
|
NSLog(@"Data is %@", d0);
|
|
|
|
[pool release];
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
exit (0);
|
|
|
|
}
|