Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rauhul committed Feb 4, 2023
1 parent 4218c1b commit ae57151
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
8 changes: 7 additions & 1 deletion Sources/System/FileStatus/FileMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

// FIXME: should the subtypes of Mode mask their rawValues to only allow their bits to be changed?

// FIXME: Document
/// The superset of access permissions and type for a file.
///
/// The following example creates an instance of the `FileMode` structure
/// from a raw octal literal and reads the file type from it:
///
/// let mode = FileMode(rawValue: 0o140000)
/// mode.type == .socket // true
@frozen
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public struct FileMode: RawRepresentable {
Expand Down
2 changes: 0 additions & 2 deletions Sources/System/FileStatus/FileStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public struct FileStatus: RawRepresentable {
public init(rawValue: CInterop.Stat) { self.rawValue = rawValue }

// FIXME: replace with swift type DeviceID that splits out major/minor
// FIXME: whats the difference between this and rDeviceID?
/// ID of device containing file.
@_alwaysEmitIntoClient
public var deviceID: CInterop.DeviceID { rawValue.st_dev }
Expand All @@ -48,7 +47,6 @@ public struct FileStatus: RawRepresentable {
@_alwaysEmitIntoClient
public var groupID: CInterop.GroupID { rawValue.st_gid }

// FIXME: whats the difference between this and deviceID?
/// Device ID.
@_alwaysEmitIntoClient
public var rDeviceID: CInterop.DeviceID { rawValue.st_rdev }
Expand Down
3 changes: 2 additions & 1 deletion Sources/System/FileStatus/FileStatusOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ extension FileDescriptor {
) -> Result<Void, Errno> {
path.withPlatformString { ptr in
nothingOrErrno(retryOnInterrupt: retryOnInterrupt) {
system_fchmodat(self.rawValue, ptr, permissions.rawValue, fcntrl.rawValue)
system_fchmodat(
self.rawValue, ptr, permissions.rawValue, fcntrl.rawValue)
}
}
}
Expand Down
21 changes: 7 additions & 14 deletions Sources/System/TimeSpecification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,18 @@ public struct TimeSpecification: RawRepresentable {
@_alwaysEmitIntoClient
private init(_ raw: CInterop.TimeSpec) { self.init(rawValue: raw) }

// FIXME: This isn't right
/// seconds since 1970
@_alwaysEmitIntoClient
public var seconds: Int { Int(rawValue.tv_sec) }
public var seconds: Int {
get { rawValue.tv_sec }
set { rawValue.tv_sec = newValue }
}

/// nanoseconds
@_alwaysEmitIntoClient
public var nanoseconds: Int { rawValue.tv_nsec }

// FIXME: This isn't right
// (-1)
static var now: TimeSpecification {
.init(rawValue: CInterop.TimeSpec(tv_sec: .min, tv_nsec: _UTIME_NOW))
}

// FIXME: This isn't right
// (-2)
static var omit: TimeSpecification {
.init(rawValue: CInterop.TimeSpec(tv_sec: .min, tv_nsec: _UTIME_OMIT))
public var nanoseconds: Int {
get { rawValue.tv_nsec }
set { rawValue.tv_nsec = newValue }
}
}

Expand Down

0 comments on commit ae57151

Please sign in to comment.