352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
-
+
-
-
+
+
|
#endif
[files makeImmutable];
return files;
}
+ (void)changeToDirectory: (OFString*)path
+ (void)changeToDirectoryAtPath: (OFString*)path
{
if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
@throw [OFChangeDirectoryFailedException
exceptionWithClass: self
path: path];
}
#ifndef _PSP
+ (void)changeModeOfFile: (OFString*)path
toMode: (mode_t)mode
+ (void)changeModeOfFileAtPath: (OFString*)path
mode: (mode_t)mode
{
# ifndef _WIN32
if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode))
@throw [OFChangeFileModeFailedException
exceptionWithClass: self
path: path
mode: mode];
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
-
+
-
+
-
-
-
+
+
+
|
exceptionWithClass: self
path: path
mode: mode];
# endif
}
#endif
+ (off_t)sizeOfFile: (OFString*)path
+ (off_t)sizeOfFileAtPath: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
return s.st_size;
}
+ (OFDate*)modificationDateOfFile: (OFString*)path
+ (OFDate*)modificationDateOfFileAtPath: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
/* FIXME: We could be more precise on some OSes */
return [OFDate dateWithTimeIntervalSince1970: s.st_mtime];
}
#if !defined(_WIN32) && !defined(_PSP)
+ (void)changeOwnerOfFile: (OFString*)path
toOwner: (OFString*)owner
group: (OFString*)group
+ (void)changeOwnerOfFileAtPath: (OFString*)path
owner: (OFString*)owner
group: (OFString*)group
{
uid_t uid = -1;
gid_t gid = -1;
if (owner == nil && group == nil)
@throw [OFInvalidArgumentException exceptionWithClass: self
selector: _cmd];
|