ObjFW  Check-in [0c99c954e2]

Overview
Comment:Pass a default mode to open().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0c99c954e2b0fcd427db3970885634186b626c3b9e2d854cb638ac474e38f2a8
User & Date: js on 2010-04-03 01:47:35
Other Links: manifest | tags
Context
2010-04-04
15:35
Allow throwing OFOutOfMemoryExceptions without size. check-in: a44005ee85 user: js tags: trunk
2010-04-03
01:47
Pass a default mode to open(). check-in: 0c99c954e2 user: js tags: trunk
01:34
Add -[writeLine:] to OFStream. check-in: da71912af5 user: js tags: trunk
Changes

Modified src/OFFile.m from [cdb8ca685b] to [d214a82c1c].

27
28
29
30
31
32
33


34
35
36
37
38
39
40
# import <windows.h>
#endif

#ifndef O_BINARY
# define O_BINARY 0
#endif



OFFile *of_stdin = nil;
OFFile *of_stdout = nil;
OFFile *of_stderr = nil;

static int parse_mode(const char *mode)
{
	if (!strcmp(mode, "r"))







>
>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# import <windows.h>
#endif

#ifndef O_BINARY
# define O_BINARY 0
#endif

#define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH

OFFile *of_stdin = nil;
OFFile *of_stdout = nil;
OFFile *of_stderr = nil;

static int parse_mode(const char *mode)
{
	if (!strcmp(mode, "r"))
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
	if ((flags = parse_mode([mode cString])) == -1) {
		c = isa;
		[super dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}

	if ((fd = open([path cString], flags)) == -1) {
		c = isa;
		[super dealloc];
		@throw [OFOpenFileFailedException newWithClass: c
							  path: path
							  mode: mode];
	}








|







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	if ((flags = parse_mode([mode cString])) == -1) {
		c = isa;
		[super dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}

	if ((fd = open([path cString], flags, DEFAULT_MODE)) == -1) {
		c = isa;
		[super dealloc];
		@throw [OFOpenFileFailedException newWithClass: c
							  path: path
							  mode: mode];
	}