@@ -410,119 +410,146 @@ public struct Stat: RawRepresentable, Sendable {
410
410
512 * blocksAllocated
411
411
}
412
412
413
- // TODO: jflat - Change time properties to UTCClock.Instant when possible.
414
-
415
- /// Time of last access, given as a `Duration` since the Epoch
413
+ /// Time of last access, given as a C `timespec` since the Epoch.
416
414
///
417
415
/// The corresponding C property is `st_atim` (or `st_atimespec` on Darwin).
418
- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
419
- public var accessTime : Duration {
416
+ @_alwaysEmitIntoClient
417
+ public var st_atim : timespec {
420
418
get {
421
419
#if SYSTEM_PACKAGE_DARWIN
422
- let timespec = rawValue. st_atimespec
420
+ rawValue. st_atimespec
423
421
#else
424
- let timespec = rawValue. st_atim
422
+ rawValue. st_atim
425
423
#endif
426
- return . seconds( timespec. tv_sec) + . nanoseconds( timespec. tv_nsec)
427
424
}
428
425
set {
429
- let ( seconds, attoseconds) = newValue. components
430
- let timespec = timespec (
431
- tv_sec: numericCast ( seconds) ,
432
- tv_nsec: numericCast ( attoseconds / 1_000_000_000 )
433
- )
434
426
#if SYSTEM_PACKAGE_DARWIN
435
- rawValue. st_atimespec = timespec
427
+ rawValue. st_atimespec = newValue
436
428
#else
437
- rawValue. st_atim = timespec
429
+ rawValue. st_atim = newValue
438
430
#endif
439
431
}
440
432
}
441
433
442
- /// Time of last modification, given as a `Duration ` since the Epoch
434
+ /// Time of last modification, given as a C `timespec ` since the Epoch.
443
435
///
444
436
/// The corresponding C property is `st_mtim` (or `st_mtimespec` on Darwin).
445
- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
446
- public var modificationTime : Duration {
437
+ @_alwaysEmitIntoClient
438
+ public var st_mtim : timespec {
447
439
get {
448
440
#if SYSTEM_PACKAGE_DARWIN
449
- let timespec = rawValue. st_mtimespec
441
+ rawValue. st_mtimespec
450
442
#else
451
- let timespec = rawValue. st_mtim
443
+ rawValue. st_mtim
452
444
#endif
453
- return . seconds( timespec. tv_sec) + . nanoseconds( timespec. tv_nsec)
454
445
}
455
446
set {
456
- let ( seconds, attoseconds) = newValue. components
457
- let timespec = timespec (
458
- tv_sec: numericCast ( seconds) ,
459
- tv_nsec: numericCast ( attoseconds / 1_000_000_000 )
460
- )
461
447
#if SYSTEM_PACKAGE_DARWIN
462
- rawValue. st_mtimespec = timespec
448
+ rawValue. st_mtimespec = newValue
463
449
#else
464
- rawValue. st_mtim = timespec
450
+ rawValue. st_mtim = newValue
465
451
#endif
466
452
}
467
453
}
468
454
469
- /// Time of last status (inode) change, given as a `Duration ` since the Epoch
455
+ /// Time of last status (inode) change, given as a C `timespec ` since the Epoch.
470
456
///
471
457
/// The corresponding C property is `st_ctim` (or `st_ctimespec` on Darwin).
472
- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
473
- public var changeTime : Duration {
458
+ @_alwaysEmitIntoClient
459
+ public var st_ctim : timespec {
474
460
get {
475
461
#if SYSTEM_PACKAGE_DARWIN
476
- let timespec = rawValue. st_ctimespec
462
+ rawValue. st_ctimespec
477
463
#else
478
- let timespec = rawValue. st_ctim
464
+ rawValue. st_ctim
479
465
#endif
480
- return . seconds( timespec. tv_sec) + . nanoseconds( timespec. tv_nsec)
481
466
}
482
467
set {
483
- let ( seconds, attoseconds) = newValue. components
484
- let timespec = timespec (
485
- tv_sec: numericCast ( seconds) ,
486
- tv_nsec: numericCast ( attoseconds / 1_000_000_000 )
487
- )
488
468
#if SYSTEM_PACKAGE_DARWIN
489
- rawValue. st_ctimespec = timespec
469
+ rawValue. st_ctimespec = newValue
490
470
#else
491
- rawValue. st_ctim = timespec
471
+ rawValue. st_ctim = newValue
492
472
#endif
493
473
}
494
474
}
495
475
496
476
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
497
- /// Time of file creation, given as a `Duration ` since the Epoch
477
+ /// Time of file creation, given as a C `timespec ` since the Epoch.
498
478
///
499
479
/// The corresponding C property is `st_birthtim` (or `st_birthtimespec` on Darwin).
500
480
/// - Note: Only available on Darwin and FreeBSD.
501
- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
502
- public var creationTime : Duration {
481
+ @_alwaysEmitIntoClient
482
+ public var st_birthtim : timespec {
503
483
get {
504
484
#if SYSTEM_PACKAGE_DARWIN
505
- let timespec = rawValue. st_birthtimespec
485
+ rawValue. st_birthtimespec
506
486
#else
507
- let timespec = rawValue. st_birthtim
487
+ rawValue. st_birthtim
508
488
#endif
509
- return . seconds( timespec. tv_sec) + . nanoseconds( timespec. tv_nsec)
510
489
}
511
490
set {
512
- let ( seconds, attoseconds) = newValue. components
513
- let timespec = timespec (
514
- tv_sec: numericCast ( seconds) ,
515
- tv_nsec: numericCast ( attoseconds / 1_000_000_000 )
516
- )
517
491
#if SYSTEM_PACKAGE_DARWIN
518
- rawValue. st_birthtimespec = timespec
492
+ rawValue. st_birthtimespec = newValue
519
493
#else
520
- rawValue. st_birthtim = timespec
494
+ rawValue. st_birthtim = newValue
521
495
#endif
522
496
}
523
497
}
524
498
#endif
525
499
500
+ // TODO: jflat - Change time properties to UTCClock.Instant when possible.
501
+
502
+ // /// Time of last access, given as a `UTCClock.Instant`
503
+ // ///
504
+ // /// The corresponding C property is `st_atim` (or `st_atimespec` on Darwin).
505
+ // public var accessTime: UTCClock.Instant {
506
+ // get {
507
+ // UTCClock.systemEpoch.advanced(by: Duration(st_atim))
508
+ // }
509
+ // set {
510
+ // st_atim = timespec(UTCClock.systemEpoch.duration(to: newValue))
511
+ // }
512
+ // }
513
+ //
514
+ // /// Time of last modification, given as a `UTCClock.Instant`
515
+ // ///
516
+ // /// The corresponding C property is `st_mtim` (or `st_mtimespec` on Darwin).
517
+ // public var modificationTime: UTCClock.Instant {
518
+ // get {
519
+ // UTCClock.systemEpoch.advanced(by: Duration(st_mtim))
520
+ // }
521
+ // set {
522
+ // st_mtim = timespec(UTCClock.systemEpoch.duration(to: newValue))
523
+ // }
524
+ // }
525
+ //
526
+ // /// Time of last status (inode) change, given as a `UTCClock.Instant`
527
+ // ///
528
+ // /// The corresponding C property is `st_ctim` (or `st_ctimespec` on Darwin).
529
+ // public var changeTime: UTCClock.Instant {
530
+ // get {
531
+ // UTCClock.systemEpoch.advanced(by: Duration(st_ctim))
532
+ // }
533
+ // set {
534
+ // st_ctim = timespec(UTCClock.systemEpoch.duration(to: newValue))
535
+ // }
536
+ // }
537
+ //
538
+ // #if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
539
+ // /// Time of file creation, given as a `UTCClock.Instant`
540
+ // ///
541
+ // /// The corresponding C property is `st_birthtim` (or `st_birthtimespec` on Darwin).
542
+ // /// - Note: Only available on Darwin and FreeBSD.
543
+ // public var creationTime: UTCClock.Instant {
544
+ // get {
545
+ // UTCClock.systemEpoch.advanced(by: Duration(st_birthtim))
546
+ // }
547
+ // set {
548
+ // st_birthtim = timespec(UTCClock.systemEpoch.duration(to: newValue))
549
+ // }
550
+ // }
551
+ // #endif
552
+
526
553
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD) || os(OpenBSD)
527
554
/// File flags
528
555
///
0 commit comments