-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMLinkController.m
57 lines (43 loc) · 1.01 KB
/
SMLinkController.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
49
50
51
52
53
54
55
56
57
//
// SMLinkController.m
// symlinky
//
// Created by Gregory Barchard on 11/10/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "SMLinkController.h"
@implementation SMLinkController
@synthesize source, destination;
- (id)init {
if (self = [super init]) {
source = [NSURL new];
destination = [NSURL new];
}
return self;
}
- (void)dealloc {
[source release];
[destination release];
[super dealloc];
}
- (void)finalize {
[source release];
[destination release];
[super finalize];
}
// Make the link
- (IBAction)link:(id)sender {
// Get the filemanager
NSFileManager *filemanager = [NSFileManager defaultManager];
// The error
NSError *error = [NSError errorWithDomain:@"net.barchard.symlinky"
code:100
userInfo:nil];
// Create the link. If an error occurs, throw a warning message
if (![filemanager createSymbolicLinkAtPath:[destination path]
withDestinationPath:[source path]
error:&error]) {
NSLog(@"Error: %@", error);
}
}
@end