Add missing files.

This commit is contained in:
Nicholas Shanks 2002-10-12 08:45:54 +00:00
parent cc7c0f07c7
commit f8552926f4
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#import <Foundation/Foundation.h>
@interface NSNumber (ResKnifeRangeExtensions)
- (BOOL)isWithinRange:(NSRange)range; // location <= self <= location+length
- (BOOL)isExclusivelyWithinRange:(NSRange)range; // location < self < location+length
- (BOOL)isBoundedByRange:(NSRange)range; // location <= self < location+length
@end

View File

@ -0,0 +1,23 @@
#import "NSNumber-Range.h"
@implementation NSNumber (ResKnifeRangeExtensions)
- (BOOL)isWithinRange:(NSRange)range // location <= self <= location+length
{
// e.g. for {6,1} a value of 6.000 will return true, as will 7.000
return [self compare:[NSNumber numberWithInt:range.location]] != NSOrderedAscending && [self compare:[NSNumber numberWithInt:range.location+range.length]] != NSOrderedDescending;
}
- (BOOL)isExclusivelyWithinRange:(NSRange)range // location < self < location+length
{
// e.g. for {6,1} a value of 6.000 will return false, 6.001 will return true, 6.999 will return true, 7.000 false
return [self compare:[NSNumber numberWithInt:range.location]] == NSOrderedDescending && [self compare:[NSNumber numberWithInt:range.location+range.length]] == NSOrderedAscending;
}
- (BOOL)isBoundedByRange:(NSRange)range // location <= self < location+length
{
// e.g. for {6,1} a value of 6.000 will return true, 6.999 will return true, 7.000 will not
return [self compare:[NSNumber numberWithInt:range.location]] != NSOrderedAscending && [self compare:[NSNumber numberWithInt:range.location+range.length]] == NSOrderedAscending;
}
@end

View File

@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
@interface NSString (ResKnifeFSSpecExtensions)
- (FSRef *)createFSRef;
- (FSSpec *)createFSSpec;
@end

View File

@ -0,0 +1,28 @@
#import "NSString-FSSpec.h"
@implementation NSString (ResKnifeFSSpecExtensions)
- (FSRef *)createFSRef
{
FSRef *fsRef = NULL;
OSStatus error = FSPathMakeRef( [self fileSystemRepresentation], &fsRef, NULL );
if( error == noErr )
return fsRef;
return NULL;
}
- (FSSpec *)createFSSpec
{
FSRef *fsRef = NULL;
FSSpec *fsSpec = NULL;
OSStatus error = FSPathMakeRef( [self fileSystemRepresentation], &fsRef, NULL );
if( error == noErr )
{
error = FSGetCatalogInfo( &fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL );
if( error == noErr )
return fsSpec;
}
return NULL;
}
@end