-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileHandling.j
More file actions
41 lines (32 loc) · 1.04 KB
/
FileHandling.j
File metadata and controls
41 lines (32 loc) · 1.04 KB
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
// (c) 2010-2011 by Anton Korenyushkin
@import "Data.j"
@import "HTTPRequest.j"
@implementation App (FileHandling)
- (CPString)URLOfFile:(File)file // public
{
return [self URL] + "code/" + [file path];
}
- (void)loadFile:(File)file // public
{
[[[HTTPRequest alloc] initWithMethod:"GET"
URL:[self URLOfFile:file]
target:file
action:@selector(setContent:)]
send];
}
- (void)saveFile:(File)file content:(CPString)newContent // public
{
var request = [[HTTPRequest alloc] initWithMethod:"PUT"
URL:[self URLOfFile:file]
target:file
action:@selector(didSave:content:)];
[request setContext:newContent];
[request send:newContent];
}
@end
@implementation File (FileHandling)
- (void)didSave:(CPString)data content:(CPString)newContent // public
{
[self setContent:newContent];
}
@end