Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / platform / DARWIN / AFSPreference / FileUtil.m
1 //
2 // FileUtil.m
3 // AFSCommander
4 //
5 // Created by Claudio Bisegni on 21/06/07.
6 // Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
7 //
8
9 #import "FileUtil.h"
10
11 @implementation FileUtil
12
13 -(id) init;
14 {
15 [super init];
16 return self;
17 }
18
19 -(void) dealloc
20 {
21 [super dealloc];
22 }
23
24 // -------------------------------------------------------------------------------
25 // startAutorization:
26 // -------------------------------------------------------------------------------
27 -(OSStatus) startAutorization
28 {
29 OSStatus err = noErr;
30 err = [[AuthUtil shared] autorize];
31 return err;
32 }
33
34 // -------------------------------------------------------------------------------
35 // autorizedMoveFile:
36 // -------------------------------------------------------------------------------
37 -(OSStatus) autorizedMoveFile:(NSString*)srcPath toPath:(NSString*)dstPath
38 {
39 OSStatus status = noErr;
40 const char *arguments[] = {[srcPath UTF8String], [dstPath UTF8String], 0L};
41 status = [[AuthUtil shared] execUnixCommand:"/bin/mv" args:arguments output:nil];
42 return status;
43 }
44
45 // -------------------------------------------------------------------------------
46 // autorizedMoveFile:
47 // -------------------------------------------------------------------------------
48 -(OSStatus) autorizedCopy:(NSString*)srcPath toPath:(NSString*)dstPath
49 {
50 OSStatus status = noErr;
51 const char *arguments[] = {[srcPath UTF8String], [dstPath UTF8String], 0L};
52 status = [[AuthUtil shared] execUnixCommand:"/bin/cp" args:arguments output:nil];
53 return status;
54 }
55
56 // -------------------------------------------------------------------------------
57 // autorizedChown:
58 // -------------------------------------------------------------------------------
59 -(OSStatus) autorizedChown:(NSString*)filePath owner:(NSString*)owner group:(NSString*)group;
60 {
61 OSStatus status = noErr;
62 NSMutableString *chownParam = [[NSMutableString alloc] init];
63 [chownParam appendString:owner];
64 [chownParam appendString:@":"];
65 [chownParam appendString:group];
66
67 const char *arguments[] = {[chownParam UTF8String], [filePath UTF8String], 0L};
68 status = [[AuthUtil shared] execUnixCommand:"/usr/sbin/chown" args:arguments output:nil];
69 [chownParam release];
70 return status;
71 }
72
73 // -------------------------------------------------------------------------------
74 // autorizedDelete:
75 // -------------------------------------------------------------------------------
76 -(OSStatus) autorizedDelete:(NSString*)destFilePath{
77 OSStatus status = noErr;
78 const char *arguments[] = {[destFilePath UTF8String], 0L};
79 status = [[AuthUtil shared] execUnixCommand:"/bin/rm" args:arguments output:nil];
80 return status;
81 }
82
83 // -------------------------------------------------------------------------------
84 // endAutorization:
85 // -------------------------------------------------------------------------------
86 -(void) endAutorization
87 {
88 [[AuthUtil shared] deautorize];
89 }
90
91 @end