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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#import "config.h"
#import <stdio.h>
#import <string.h>
#import <unistd.h>
#import <sys/types.h>
#import <sys/stat.h>
#import "OFFile.h"
#import "OFExceptions.h"
@implementation OFFile
+ newWithPath: (const char*)path
andMode: (const char*)mode
{
return [[self alloc] initWithPath: path
andMode: mode];
}
+ (BOOL)changeModeOfFile: (const char*)path
toMode: (mode_t)mode
{
// FIXME: On error, throw exception
return (chmod(path, mode) == 0 ? YES : NO);
}
+ (BOOL)changeOwnerOfFile: (const char*)path
toOwner: (uid_t)owner
andGroup: (gid_t)group
{
// FIXME: On error, throw exception
return (chown(path, owner, group) == 0 ? YES : NO);
}
+ (BOOL)delete: (const char*)path
{
// FIXME: On error, throw exception
return (unlink(path) == 0 ? YES : NO);
}
+ (BOOL)link: (const char*)src
to: (const char*)dest
{
// FIXME: On error, throw exception
return (link(src, dest) == 0 ? YES : NO);
}
+ (BOOL)symlink: (const char*)src
to: (const char*)dest
{
// FIXME: On error, throw exception
return (symlink(src, dest) == 0 ? YES : NO);
}
- initWithPath: (const char*)path
andMode: (const char*)mode
{
if ((self = [super init])) {
if ((fp = fopen(path, mode)) == NULL)
@throw [OFOpenFileFailedException newWithObject: self
|
>
>
>
|
>
>
|
|
>
>
|
|
>
|
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#import "config.h"
#import <stdio.h>
#import <string.h>
#import <unistd.h>
#ifndef _WIN32
#import <sys/types.h>
#import <sys/stat.h>
#endif
#import "OFFile.h"
#import "OFExceptions.h"
@implementation OFFile
+ newWithPath: (const char*)path
andMode: (const char*)mode
{
return [[self alloc] initWithPath: path
andMode: mode];
}
#ifndef _WIN32
+ (BOOL)changeModeOfFile: (const char*)path
toMode: (mode_t)mode
{
// FIXME: On error, throw exception
return (chmod(path, mode) == 0 ? YES : NO);
}
#endif
#ifndef _WIN32
+ (BOOL)changeOwnerOfFile: (const char*)path
toOwner: (uid_t)owner
andGroup: (gid_t)group
{
// FIXME: On error, throw exception
return (chown(path, owner, group) == 0 ? YES : NO);
}
#endif
+ (BOOL)delete: (const char*)path
{
// FIXME: On error, throw exception
return (unlink(path) == 0 ? YES : NO);
}
#ifndef _WIN32
+ (BOOL)link: (const char*)src
to: (const char*)dest
{
// FIXME: On error, throw exception
return (link(src, dest) == 0 ? YES : NO);
}
+ (BOOL)symlink: (const char*)src
to: (const char*)dest
{
// FIXME: On error, throw exception
return (symlink(src, dest) == 0 ? YES : NO);
}
#endif
- initWithPath: (const char*)path
andMode: (const char*)mode
{
if ((self = [super init])) {
if ((fp = fopen(path, mode)) == NULL)
@throw [OFOpenFileFailedException newWithObject: self
|