CoreFW  Diff

Differences From Artifact [6570f4dc53]:

To Artifact [222c0e621d]:


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
168
169
170
171
172
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
168
169
170
171
172







-
-
+
+
















-
+







ctor(void *ptr, va_list args)
{
	CFWFile *file = ptr;
	const char *path = va_arg(args, const char*);
	const char *mode = va_arg(args, const char*);
	int flags;

	/* Make sure we have a valid pointer in case we error out */
	file->stream.ops = NULL;
	/* Make sure we have a valid file in case we error out */
	cfw_stream->ctor(ptr, args);
	file->eof = false;

	if ((flags = parse_mode(mode)) == -1)
		return false;

	if ((file->fd = open(path, flags, DEFAULT_MODE)) == -1)
		return false;

	file->stream.ops = &stream_ops;

	return true;
}

static void
dtor(void *ptr)
{
	cfw_stream_close(ptr);
	cfw_stream->dtor(ptr);
}

static CFWClass class = {
	.name = "CFWFile",
	.size = sizeof(CFWFile),
	.ctor = ctor,
	.dtor = dtor