ObjFW  Diff

Differences From Artifact [8e748f0d5d]:

To Artifact [7e04efd7c9]:


9
10
11
12
13
14
15

16
17
18
19
20

21
22
23
24
25
26
27
9
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28







+




-
+







 * the packaging of this file.
 */

#import <stdio.h>
#import <sys/types.h>

#import "OFObject.h"
#import "OFStream.h"

/**
 * The OFFile class provides functions to read, write and manipulate files.
 */
@interface OFFile: OFObject
@interface OFFile: OFObject <OFStream>
{
	FILE *fp;
}

/**
 * \param path The path to the file to open as a C string
 * \param mode The mode in which the file should be opened as a C string
104
105
106
107
108
109
110
111
112
113














114
115
116
117
118
119
120
121
122

123
124









125
126
127
128
129
130
131
132
133
134
135
136













137
105
106
107
108
109
110
111



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153



154
155
156
157
158
159
160
161
162
163
164
165
166
167







-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+









+
-
-
+
+
+
+
+
+
+
+
+









-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+

 * \param buf The buffer into which the data is read
 * \param size The size of the data that should be read.
 *	  The buffer MUST be at least size * nitems big!
 * \param nitems nitem The number of items to read
 *	  The buffer MUST be at least size * nitems big!
 * \return The number of bytes read
 */
- (size_t)readIntoBuffer: (uint8_t*)buf
		withSize: (size_t)size
	       andNItems: (size_t)nitems;
- (size_t)readNItems: (size_t)nitems
	      ofSize: (size_t)size
	  intoBuffer: (uint8_t*)buf;

/**
 * Reads from the file into a buffer.
 *
 * \param buf The buffer into which the data is read
 * \param size The size of the data that should be read.
 *	  The buffer MUST be at least size big!
 * \return The number of bytes read
 */
- (size_t)readNBytes: (size_t)size
	  intoBuffer: (uint8_t*)buf;

/**
 * Reads from the file into a new buffer.
 *
 * \param size The size of the data that should be read
 * \param nitem The number of items to read
 * \return A new buffer with the data read.
 *	   It is part of the memory pool of the OFFile.
 */
- (uint8_t*)readNItems: (size_t)nitems
- (uint8_t*)readWithSize: (size_t)size
	       andNItems: (size_t)nitems;
		ofSize: (size_t)size;
/**
 * Reads from the file into a new buffer.
 *
 * \param size The size of the data that should be read
 * \return A new buffer with the data read.
 *	   It is part of the memory pool of the OFFile.
 */
- (uint8_t*)readNBytes: (size_t)size;

/**
 * Writes from a buffer into the file.
 *
 * \param buf The buffer from which the data is written to the file
 * \param size The size of the data that should be written
 * \param nitem The number of items to write
 * \return The number of bytes written
 */
- (size_t)writeBuffer: (uint8_t*)buf
	     withSize: (size_t)size
	    andNItems: (size_t)nitems;
- (size_t)writeNItems: (size_t)nitems
	       ofSize: (size_t)size
	   fromBuffer: (uint8_t*)buf;

/**
 * Writes from a buffer into the file.
 *
 * \param buf The buffer from which the data is written to the file
 * \param size The size of the data that should be written
 * \return The number of bytes written
 */
- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (uint8_t*)buf;
@end