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
0 commit comments