-
Notifications
You must be signed in to change notification settings - Fork 1
/
KinemeStringWithFile.m
48 lines (39 loc) · 1.14 KB
/
KinemeStringWithFile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "stdio.h"
#import "KinemeStringWithFile.h"
@implementation KinemeStringWithFile
+ (QCPatchExecutionMode)executionModeWithIdentifier:(id)fp8
{
return kQCPatchExecutionModeProvider;
}
+ (BOOL)allowsSubpatchesWithIdentifier:(id)fp8
{
return FALSE;
}
- (id)initWithIdentifier:(id)fp8
{
if(self=[super initWithIdentifier:fp8])
{
[[self userInfo] setObject:@"Kineme String With File" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(id)openglcontext time:(double)time arguments:(id)arguments
{
if( [inputFilePath wasUpdated] || ([inputUpdate wasUpdated] && [inputUpdate booleanValue]))
{
// manual retain/release is faster than roundtrip through an autorelease pool
NSString *path = KIExpandPath(self,[inputFilePath stringValue]);
NSData *d = [[NSData alloc] initWithContentsOfFile: path];
if(d)
{
NSString *s = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
if(s == nil) // UTF8 fails for some ascii string (foundation bug?)
s = [[NSString alloc] initWithData: d encoding: NSASCIIStringEncoding];
[outputFileContent setStringValue:s];
[d release];
[s release];
}
}
return YES;
}
@end