234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
handle = open(
[path cStringWithEncoding: [OFLocale encoding]],
flags, 0666);
# endif
if (handle == -1)
@throw [OFOpenItemFailedException
exceptionWithURL: [OFURL fileURLWithPath: path]
mode: mode
errNo: errno];
#else
handle = OFAllocMemory(1, sizeof(*handle));
@try {
if ((flags = parseMode(mode.UTF8String,
&handle->append)) == -1)
@throw [OFInvalidArgumentException exception];
if ((handle->handle = Open([path cStringWithEncoding:
[OFLocale encoding]], flags)) == 0) {
int errNo;
OFURL *URL;
switch (IoErr()) {
case ERROR_OBJECT_IN_USE:
case ERROR_DISK_NOT_VALIDATED:
errNo = EBUSY;
break;
case ERROR_OBJECT_NOT_FOUND:
|
|
|
|
<
|
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
handle = open(
[path cStringWithEncoding: [OFLocale encoding]],
flags, 0666);
# endif
if (handle == -1)
@throw [OFOpenItemFailedException
exceptionWithPath: path
mode: mode
errNo: errno];
#else
handle = OFAllocMemory(1, sizeof(*handle));
@try {
if ((flags = parseMode(mode.UTF8String,
&handle->append)) == -1)
@throw [OFInvalidArgumentException exception];
if ((handle->handle = Open([path cStringWithEncoding:
[OFLocale encoding]], flags)) == 0) {
int errNo;
switch (IoErr()) {
case ERROR_OBJECT_IN_USE:
case ERROR_DISK_NOT_VALIDATED:
errNo = EBUSY;
break;
case ERROR_OBJECT_NOT_FOUND:
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
errNo = EACCES;
break;
default:
errNo = 0;
break;
}
URL = [OFURL fileURLWithPath: path];
@throw [OFOpenItemFailedException
exceptionWithURL: URL
mode: mode
errNo: errNo];
}
if (handle->append) {
# if defined(OF_MORPHOS)
if (Seek64(handle->handle, 0,
OFFSET_END) == -1) {
# elif defined(OF_AMIGAOS4)
if (ChangeFilePosition(handle->handle, 0,
OFFSET_END) == -1) {
# else
if (Seek(handle->handle, 0, OFFSET_END) == -1) {
# endif
OFURL *URL =
[OFURL fileURLWithPath: path];
Close(handle->handle);
@throw [OFOpenItemFailedException
exceptionWithURL: URL
mode: mode
errNo: EIO];
}
}
Forbid();
handle->previous = NULL;
handle->next = firstHandle;
|
<
|
|
|
<
<
|
|
|
|
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
errNo = EACCES;
break;
default:
errNo = 0;
break;
}
@throw [OFOpenItemFailedException
exceptionWithPath: path
mode: mode
errNo: errNo];
}
if (handle->append) {
# if defined(OF_MORPHOS)
if (Seek64(handle->handle, 0,
OFFSET_END) == -1) {
# elif defined(OF_AMIGAOS4)
if (ChangeFilePosition(handle->handle, 0,
OFFSET_END) == -1) {
# else
if (Seek(handle->handle, 0, OFFSET_END) == -1) {
# endif
Close(handle->handle);
@throw [OFOpenItemFailedException
exceptionWithPath: path
mode: mode
errNo: EIO];
}
}
Forbid();
handle->previous = NULL;
handle->next = firstHandle;
|