62 lines
743 B
Mathematica
62 lines
743 B
Mathematica
|
//
|
||
|
// FileSource.m
|
||
|
// FileSource
|
||
|
//
|
||
|
// Created by Vincent Spader on 3/1/07.
|
||
|
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "FileSource.h"
|
||
|
|
||
|
|
||
|
@implementation FileSource
|
||
|
|
||
|
- (BOOL)buffered
|
||
|
{
|
||
|
return NO;
|
||
|
}
|
||
|
|
||
|
- (BOOL)open:(NSURL *)url
|
||
|
{
|
||
|
_fd = fopen([[url path] UTF8String], "r");
|
||
|
|
||
|
return (_fd != NULL);
|
||
|
}
|
||
|
|
||
|
- (NSDictionary *)properties
|
||
|
{
|
||
|
return nil;
|
||
|
}
|
||
|
|
||
|
- (BOOL)seekable
|
||
|
{
|
||
|
return YES;
|
||
|
}
|
||
|
|
||
|
- (BOOL)seek:(long)position whence:(int)whence
|
||
|
{
|
||
|
return (fseek(_fd, position, whence) == 0);
|
||
|
}
|
||
|
|
||
|
- (long)tell
|
||
|
{
|
||
|
return ftell(_fd);
|
||
|
}
|
||
|
|
||
|
- (int)read:(void *)buffer amount:(int)amount
|
||
|
{
|
||
|
return fread(buffer, 1, amount, _fd);
|
||
|
}
|
||
|
|
||
|
- (void)close
|
||
|
{
|
||
|
fclose(_fd);
|
||
|
}
|
||
|
|
||
|
+ (NSArray *)schemes
|
||
|
{
|
||
|
return [NSArray arrayWithObject:@"file"];
|
||
|
}
|
||
|
|
||
|
@end
|