ObjFW  Diff

Differences From Artifact [e3b833eee4]:

  • File src/OFFile.m — part of check-in [c83137e7cd] at 2008-12-11 13:43:35 on branch trunk — Remove - close from OFStream protocol.
    The reason is that closing a file isn't too useful, because an OFFile
    object can't be reused, whereas an OFTCPSocket can. So only the
    OFTCPSocket should have closed. Plus, we don't need to handle the case
    that someone tried to read from / write to a closed OFFile. (user: js, size: 3186) [annotate] [blame] [check-ins using]

To Artifact [8a9dff998b]:


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