ObjFW  Check-in [c83137e7cd]

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c83137e7cd31a6a7878c620905165f76b8bcd92043b6cb22b6819b7135fb984a
User & Date: js on 2008-12-11 13:43:35
Other Links: manifest | tags
Context
2008-12-11
13:53
Allow initialization without NItems for OFReadOrWriteFailedException. check-in: 5168142abe user: js tags: trunk
13:43
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.
check-in: c83137e7cd user: js tags: trunk
2008-12-10
20:53
Fix FIXMEs in OFString; new exception. check-in: 4f7378978c user: js tags: trunk
Changes

Modified src/OFExceptions.h from [d80b50b5d0] to [7dd17fb763].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"

/* FIXME: Exceptions should include which type of error occoured (fopen etc.) */

/**
 * The OFException class is the base class for all exceptions in ObjFW.
 */
@interface OFException: OFObject
{
	id   object;
	char *string;













<
<







1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"



/**
 * The OFException class is the base class for all exceptions in ObjFW.
 */
@interface OFException: OFObject
{
	id   object;
	char *string;

Modified src/OFFile.m from [0b28d6c4b4] to [e3b833eee4].

75
76
77
78
79
80
81

82
83
84
85
86
87
88
	}
	return self;
}

- free
{
	fclose(fp);

	return [super free];
}

- (BOOL)atEndOfFile
{
	return (feof(fp) == 0 ? NO : YES);
}







>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
	}
	return self;
}

- free
{
	fclose(fp);

	return [super free];
}

- (BOOL)atEndOfFile
{
	return (feof(fp) == 0 ? NO : YES);
}
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

- (size_t)writeCString: (const char*)str
{
	return [self writeNItems: strlen(str)
			  ofSize: 1
		      fromBuffer: (const uint8_t*)str];
}

- close
{
	if (fclose(fp)) {
		/* FIXME: Throw exception */
		return nil;
	}

	return self;
}
@end







<
<
<
<
<
<
<
<
<
<

161
162
163
164
165
166
167










168

- (size_t)writeCString: (const char*)str
{
	return [self writeNItems: strlen(str)
			  ofSize: 1
		      fromBuffer: (const uint8_t*)str];
}










@end

Modified src/OFStream.h from [a9317063cc] to [7bc3490907].

46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 * Writes a C string into the stream, without the trailing zero.
 *
 * \param str The C string from which the data is written to the stream
 * \return The number of bytes written
 */
- (size_t)writeCString: (const char*)str;

/**
 * Closes the stream.
 */
- close;
@end







<
<
<
<
<

46
47
48
49
50
51
52





53
/**
 * Writes a C string into the stream, without the trailing zero.
 *
 * \param str The C string from which the data is written to the stream
 * \return The number of bytes written
 */
- (size_t)writeCString: (const char*)str;





@end

Modified src/OFTCPSocket.h from [01c69a8231] to [dc54bd8b6a].

72
73
74
75
76
77
78





79
 */
- listen;

/**
 * Accept an incoming connection.
 */
- (OFTCPSocket*)accept;





@end







>
>
>
>
>

72
73
74
75
76
77
78
79
80
81
82
83
84
 */
- listen;

/**
 * Accept an incoming connection.
 */
- (OFTCPSocket*)accept;

/**
 * Closes the socket.
 */
- close;
@end