ObjFW  Diff

Differences From Artifact [57318981b1]:

To Artifact [c917d0f228]:


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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <sys/stat.h>
#endif

#import "OFFile.h"
#import "OFExceptions.h"

@implementation OFFile
+ fileWithPath: (const char*)path
       andMode: (const char*)mode
{
	return [[[OFFile alloc] initWithPath: path
				   andMode: mode] autorelease];
}

+ (void)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode
{
	/*
	 * FIXME: On error, throw exception
	 * FIXME: On Win32, change write access
	 */
#ifndef _WIN32
	chmod(path, mode);
#endif
}

+ (void)changeOwnerOfFile: (const char*)path
		  toOwner: (uid_t)owner
		 andGroup: (gid_t)group
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	chown(path, owner, group);
#endif
}

+ (void)delete: (const char*)path
{
	/* FIXME: On error, throw exception */
	unlink(path);
}

+ (void)link: (const char*)src
	  to: (const char*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	link(src, dest);
#endif
}

+ (void)symlink: (const char*)src
	     to: (const char*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	symlink(src, dest);
#endif
}

- initWithPath: (const char*)path
       andMode: (const char*)mode
{
	Class c;

	self = [super init];

	if ((fp = fopen(path, mode)) == NULL) {
		c = isa;
		[super dealloc];
		@throw [OFOpenFileFailedException newWithClass: c 
						       andPath: path
						       andMode: mode];
	}








|
|





|







|



|





|



|


|


|
|



|



|
|



|



|
|





|







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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <sys/stat.h>
#endif

#import "OFFile.h"
#import "OFExceptions.h"

@implementation OFFile
+ fileWithPath: (OFString*)path
       andMode: (OFString*)mode
{
	return [[[OFFile alloc] initWithPath: path
				   andMode: mode] autorelease];
}

+ (void)changeModeOfFile: (OFString*)path
		  toMode: (mode_t)mode
{
	/*
	 * FIXME: On error, throw exception
	 * FIXME: On Win32, change write access
	 */
#ifndef _WIN32
	chmod([path cString], mode);
#endif
}

+ (void)changeOwnerOfFile: (OFString*)path
		  toOwner: (uid_t)owner
		 andGroup: (gid_t)group
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	chown([path cString], owner, group);
#endif
}

+ (void)delete: (OFString*)path
{
	/* FIXME: On error, throw exception */
	unlink([path cString]);
}

+ (void)link: (OFString*)src
	  to: (OFString*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	link([src cString], [dest cString]);
#endif
}

+ (void)symlink: (OFString*)src
	     to: (OFString*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	symlink([src cString], [dest cString]);
#endif
}

- initWithPath: (OFString*)path
       andMode: (OFString*)mode
{
	Class c;

	self = [super init];

	if ((fp = fopen([path cString], [mode cString])) == NULL) {
		c = isa;
		[super dealloc];
		@throw [OFOpenFileFailedException newWithClass: c 
						       andPath: path
						       andMode: mode];
	}