Skip to content

Commit 166f98d

Browse files
committed
Remove filemodeother
1 parent a9272da commit 166f98d

File tree

7 files changed

+326
-173
lines changed

7 files changed

+326
-173
lines changed

Sources/System/FileStatus/FileFlags.swift

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// FIXME: Document
1313
@frozen
1414
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
15-
public struct FileFlags: OptionSet {
15+
public struct FileFlags: OptionSet, Hashable, Codable {
1616
/// The raw C file flags.
1717
@_alwaysEmitIntoClient
1818
public let rawValue: CInterop.FileFlags
@@ -64,17 +64,17 @@ public struct FileFlags: OptionSet {
6464
@available(*, unavailable, renamed: "opaque")
6565
public static var UF_OPAQUE: FileFlags { opaque }
6666

67-
#if os(FreeBSD)
68-
/// The file may not be removed or renamed. Modifiable by file owner or super-user.
69-
///
70-
/// The corresponding C constant is `UF_NOUNLINK`
71-
@_alwaysEmitIntoClient
72-
public static var noUnlink: FileFlags { FileFlags(_UF_NOUNLINK) }
73-
74-
@_alwaysEmitIntoClient
75-
@available(*, unavailable, renamed: "noUnlink")
76-
public static var UF_NOUNLINK: FileFlags { noUnlink }
77-
#endif
67+
// #if os(FreeBSD)
68+
// /// The file may not be removed or renamed. Modifiable by file owner or super-user.
69+
// ///
70+
// /// The corresponding C constant is `UF_NOUNLINK`
71+
// @_alwaysEmitIntoClient
72+
// public static var noUnlink: FileFlags { FileFlags(_UF_NOUNLINK) }
73+
//
74+
// @_alwaysEmitIntoClient
75+
// @available(*, unavailable, renamed: "noUnlink")
76+
// public static var UF_NOUNLINK: FileFlags { noUnlink }
77+
// #endif
7878

7979
/// The file is compressed (some file-systems). Modifiable by file owner or super-user.
8080
///
@@ -166,17 +166,17 @@ public struct FileFlags: OptionSet {
166166
@available(*, unavailable, renamed: "superUserNoUnlink")
167167
public static var SF_NOUNLINK: FileFlags { superUserNoUnlink }
168168

169-
#if os(FreeBSD)
170-
/// The file is a snapshot file. Only modifiable by the super-user.
171-
///
172-
/// The corresponding C constant is `SF_SNAPSHOT`
173-
@_alwaysEmitIntoClient
174-
public static var superUserSnapshot: FileFlags { FileFlags(_SF_SNAPSHOT) }
175-
176-
@_alwaysEmitIntoClient
177-
@available(*, unavailable, renamed: "superUserSnapshot")
178-
public static var SF_SNAPSHOT: FileFlags { superUserSnapshot }
179-
#endif
169+
// #if os(FreeBSD)
170+
// /// The file is a snapshot file. Only modifiable by the super-user.
171+
// ///
172+
// /// The corresponding C constant is `SF_SNAPSHOT`
173+
// @_alwaysEmitIntoClient
174+
// public static var superUserSnapshot: FileFlags { FileFlags(_SF_SNAPSHOT) }
175+
//
176+
// @_alwaysEmitIntoClient
177+
// @available(*, unavailable, renamed: "superUserSnapshot")
178+
// public static var SF_SNAPSHOT: FileFlags { superUserSnapshot }
179+
// #endif
180180

181181
/// The file is a firmlink. Only modifiable by the super-user.
182182
///
@@ -199,4 +199,36 @@ public struct FileFlags: OptionSet {
199199
public static var SF_DATALESS: FileFlags { kernelDataless }
200200
}
201201

202+
// @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
203+
extension FileFlags
204+
: CustomStringConvertible, CustomDebugStringConvertible
205+
{
206+
/// A textual representation of the file permissions.
207+
@inline(never)
208+
public var description: String {
209+
let descriptions: [(Element, StaticString)] = [
210+
(.noDump, ".noDump"),
211+
(.immutable, ".immutable"),
212+
(.appendOnly, ".appendOnly"),
213+
(.opaque, ".opaque"),
214+
(.compressed, ".compressed"),
215+
(.tracked, ".tracked"),
216+
(.dataVault, ".dataVault"),
217+
(.hidden, ".hidden"),
218+
(.superUserArchived, ".superUserArchived"),
219+
(.superUserImmutable, ".superUserImmutable"),
220+
(.superUserAppend, ".superUserAppend"),
221+
(.superUserRestricted, ".superUserRestricted"),
222+
(.superUserNoUnlink, ".superUserNoUnlink"),
223+
(.superUserFirmlink, ".superUserFirmlink"),
224+
(.kernelDataless, ".kernelDataless"),
225+
]
226+
227+
return _buildDescription(descriptions)
228+
}
229+
230+
/// A textual representation of the file permissions, suitable for debugging.
231+
public var debugDescription: String { self.description }
232+
}
233+
202234
#endif

Sources/System/FileStatus/FileMode/FileMode.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ public struct FileMode: RawRepresentable {
3030
set { rawValue = (rawValue & ~_MODE_PERMISSIONS) | (newValue.rawValue & _MODE_PERMISSIONS ) }
3131
}
3232

33-
/// Subset of mode for accessing and modifying file mode other.
34-
@_alwaysEmitIntoClient
35-
public var other: FileModeOther {
36-
get { FileModeOther(rawValue: rawValue & _MODE_OTHER) }
37-
set { rawValue = (rawValue & ~_MODE_OTHER) | (newValue.rawValue & _MODE_OTHER ) }
38-
}
39-
4033
/// Subset of mode for accessing and modifying file type.
4134
@_alwaysEmitIntoClient
4235
public var type: FileType {

Sources/System/FileStatus/FileMode/FileModeOther.swift

Lines changed: 0 additions & 69 deletions
This file was deleted.

Sources/System/FileStatus/FileMode/FilePermissions.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,12 @@ public struct FilePermissions: OptionSet, Hashable, Codable {
118118
///
119119
/// For more information, see the `setuid(2)` man page.
120120
@_alwaysEmitIntoClient
121-
@available(*, deprecated, renamed: "FileModeOther.setUserID")
122121
public static var setUserID: FilePermissions { FilePermissions(0o4000) }
123122

124123
/// Indicates that the file is executed as the group.
125124
///
126125
/// For more information, see the `setgid(2)` man page.
127126
@_alwaysEmitIntoClient
128-
@available(*, deprecated, renamed: "FileModeOther.setGroupID")
129127
public static var setGroupID: FilePermissions { FilePermissions(0o2000) }
130128

131129
/// Indicates that executable's text segment
@@ -134,7 +132,6 @@ public struct FilePermissions: OptionSet, Hashable, Codable {
134132
/// For more information, see the `chmod(2)` man page's
135133
/// discussion of `S_ISVTX` (the sticky bit).
136134
@_alwaysEmitIntoClient
137-
@available(*, deprecated, renamed: "FileModeOther.saveText")
138135
public static var saveText: FilePermissions { FilePermissions(0o1000) }
139136
}
140137

Sources/System/FileStatus/FileStatus.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public struct FileStatus: RawRepresentable {
2323
public init(rawValue: CInterop.Stat) { self.rawValue = rawValue }
2424

2525
// FIXME: replace with swift type DeviceId that splits out major/minor
26+
// FIXME: whats the difference between this and rDeviceId?
2627
/// ID of device containing file.
2728
@_alwaysEmitIntoClient
2829
public var deviceId: CInterop.DeviceId { rawValue.st_dev }
@@ -50,7 +51,7 @@ public struct FileStatus: RawRepresentable {
5051
// FIXME: whats the difference between this and deviceId?
5152
/// Device ID.
5253
@_alwaysEmitIntoClient
53-
public var rDeviceID: CInterop.DeviceId { rawValue.st_rdev }
54+
public var rDeviceId: CInterop.DeviceId { rawValue.st_rdev }
5455

5556
/// Time of last access.
5657
@_alwaysEmitIntoClient
@@ -76,7 +77,7 @@ public struct FileStatus: RawRepresentable {
7677
@_alwaysEmitIntoClient
7778
public var blockCount: CInterop.BlockCount { rawValue.st_blocks }
7879

79-
/// Optimal blocksize for I/O.
80+
/// Optimal block size for I/O.
8081
@_alwaysEmitIntoClient
8182
public var blockSize: CInterop.BlockSize { rawValue.st_blksize }
8283

0 commit comments

Comments
 (0)