5 // Created by Claudio Bisegni on
21/06/07.
6 // Copyright
2007 INFN
- National Institute of Nuclear Physics.
All rights reserved.
11 @implementation FileUtil
24 // -------------------------------------------------------------------------------
26 // -------------------------------------------------------------------------------
27 -(OSStatus
) startAutorization
30 err
= [[AuthUtil shared
] autorize
];
34 // -------------------------------------------------------------------------------
36 // -------------------------------------------------------------------------------
37 -(OSStatus
) autorizedMoveFile
:(NSString
*)srcPath toPath
:(NSString
*)dstPath
39 OSStatus status
= noErr
;
40 const
char *arguments
[] = {[srcPath UTF8String
], [dstPath UTF8String
], 0L};
41 status
= [[AuthUtil shared
] execUnixCommand
:"
/bin
/mv" args
:arguments output
:nil
];
45 // -------------------------------------------------------------------------------
47 // -------------------------------------------------------------------------------
48 -(OSStatus
) autorizedCopy
:(NSString
*)srcPath toPath
:(NSString
*)dstPath
50 OSStatus status
= noErr
;
51 const
char *arguments
[] = {[srcPath UTF8String
], [dstPath UTF8String
], 0L};
52 status
= [[AuthUtil shared
] execUnixCommand
:"
/bin
/cp" args
:arguments output
:nil
];
56 // -------------------------------------------------------------------------------
58 // -------------------------------------------------------------------------------
59 -(OSStatus
) autorizedChown
:(NSString
*)filePath owner
:(NSString
*)owner group
:(NSString
*)group
;
61 OSStatus status
= noErr
;
62 NSMutableString
*chownParam
= [[NSMutableString alloc
] init
];
63 [chownParam appendString
:owner
];
64 [chownParam appendString
:@"
:"
];
65 [chownParam appendString
:group
];
67 const
char *arguments
[] = {[chownParam UTF8String
], [filePath UTF8String
], 0L};
68 status
= [[AuthUtil shared
] execUnixCommand
:"
/usr
/sbin
/chown" args
:arguments output
:nil
];
73 // -------------------------------------------------------------------------------
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
];
83 // -------------------------------------------------------------------------------
85 // -------------------------------------------------------------------------------
86 -(void
) endAutorization
88 [[AuthUtil shared
] deautorize
];