|  | 
|  | 1 | +/* | 
|  | 2 | + This source file is part of the Swift System open source project | 
|  | 3 | + | 
|  | 4 | + Copyright (c) 2021 Apple Inc. and the Swift System project authors | 
|  | 5 | + Licensed under Apache License v2.0 with Runtime Library Exception | 
|  | 6 | + | 
|  | 7 | + See https://swift.org/LICENSE.txt for license information | 
|  | 8 | + */ | 
|  | 9 | + | 
|  | 10 | +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) | 
|  | 11 | + | 
|  | 12 | +// FIXME: Document | 
|  | 13 | +@frozen | 
|  | 14 | +// @available(macOS 12, iOS 15.0, watchOS 8.0, tvOS 15.0, *) | 
|  | 15 | +public struct FileFlags: OptionSet { | 
|  | 16 | +  /// The raw C file flags. | 
|  | 17 | +  @_alwaysEmitIntoClient | 
|  | 18 | +  public let rawValue: CInterop.FileFlags | 
|  | 19 | + | 
|  | 20 | +  /// Create a strongly-typed file flags from a raw C value. | 
|  | 21 | +  @_alwaysEmitIntoClient | 
|  | 22 | +  public init(rawValue: CInterop.FileFlags) { self.rawValue = rawValue } | 
|  | 23 | + | 
|  | 24 | +  @_alwaysEmitIntoClient | 
|  | 25 | +  private init(_ raw: CInterop.FileFlags) { self.init(rawValue: raw) } | 
|  | 26 | + | 
|  | 27 | +  /// Do not dump the file. Modifiable by file owner or super-user. | 
|  | 28 | +  /// | 
|  | 29 | +  /// The corresponding C constant is `UF_NODUMP` | 
|  | 30 | +  @_alwaysEmitIntoClient | 
|  | 31 | +  public static var noDump: FileFlags { FileFlags(_UF_NODUMP) } | 
|  | 32 | + | 
|  | 33 | +  @_alwaysEmitIntoClient | 
|  | 34 | +  @available(*, unavailable, renamed: "noDump") | 
|  | 35 | +  public static var UF_NODUMP: FileFlags { noDump } | 
|  | 36 | + | 
|  | 37 | +  /// The file may not be changed. Modifiable by file owner or super-user. | 
|  | 38 | +  /// | 
|  | 39 | +  /// The corresponding C constant is `UF_IMMUTABLE` | 
|  | 40 | +  @_alwaysEmitIntoClient | 
|  | 41 | +  public static var immutable: FileFlags { FileFlags(_UF_IMMUTABLE) } | 
|  | 42 | + | 
|  | 43 | +  @_alwaysEmitIntoClient | 
|  | 44 | +  @available(*, unavailable, renamed: "immutable") | 
|  | 45 | +  public static var UF_IMMUTABLE: FileFlags { immutable } | 
|  | 46 | + | 
|  | 47 | +  /// The file may only be appended to. Modifiable by file owner or super-user. | 
|  | 48 | +  /// | 
|  | 49 | +  /// The corresponding C constant is `UF_APPEND` | 
|  | 50 | +  @_alwaysEmitIntoClient | 
|  | 51 | +  public static var appendOnly: FileFlags { FileFlags(_UF_APPEND) } | 
|  | 52 | + | 
|  | 53 | +  @_alwaysEmitIntoClient | 
|  | 54 | +  @available(*, unavailable, renamed: "appendOnly") | 
|  | 55 | +  public static var UF_APPEND: FileFlags { appendOnly } | 
|  | 56 | + | 
|  | 57 | +  /// The directory is opaque when viewed through a union stack. Modifiable by file owner or super-user. | 
|  | 58 | +  /// | 
|  | 59 | +  /// The corresponding C constant is `UF_OPAQUE` | 
|  | 60 | +  @_alwaysEmitIntoClient | 
|  | 61 | +  public static var opaque: FileFlags { FileFlags(_UF_OPAQUE) } | 
|  | 62 | + | 
|  | 63 | +  @_alwaysEmitIntoClient | 
|  | 64 | +  @available(*, unavailable, renamed: "opaque") | 
|  | 65 | +  public static var UF_OPAQUE: FileFlags { opaque } | 
|  | 66 | + | 
|  | 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 | 
|  | 78 | + | 
|  | 79 | +  /// The file is compressed (some file-systems). Modifiable by file owner or super-user. | 
|  | 80 | +  /// | 
|  | 81 | +  /// The corresponding C constant is `UF_COMPRESSED` | 
|  | 82 | +  @_alwaysEmitIntoClient | 
|  | 83 | +  public static var compressed: FileFlags { FileFlags(_UF_COMPRESSED) } | 
|  | 84 | + | 
|  | 85 | +  @_alwaysEmitIntoClient | 
|  | 86 | +  @available(*, unavailable, renamed: "compressed") | 
|  | 87 | +  public static var UF_COMPRESSED: FileFlags { compressed } | 
|  | 88 | + | 
|  | 89 | +  /// No notifications will be issued for deletes or renames. Modifiable by file owner or super-user. | 
|  | 90 | +  /// | 
|  | 91 | +  /// The corresponding C constant is `UF_TRACKED` | 
|  | 92 | +  @_alwaysEmitIntoClient | 
|  | 93 | +  public static var tracked: FileFlags { FileFlags(_UF_TRACKED) } | 
|  | 94 | + | 
|  | 95 | +  @_alwaysEmitIntoClient | 
|  | 96 | +  @available(*, unavailable, renamed: "tracked") | 
|  | 97 | +  public static var UF_TRACKED: FileFlags { tracked } | 
|  | 98 | + | 
|  | 99 | +  /// The file requires entitlement required for reading and writing. Modifiable by file owner or super-user. | 
|  | 100 | +  /// | 
|  | 101 | +  /// The corresponding C constant is `UF_DATAVAULT` | 
|  | 102 | +  @_alwaysEmitIntoClient | 
|  | 103 | +  public static var dataVault: FileFlags { FileFlags(_UF_DATAVAULT) } | 
|  | 104 | + | 
|  | 105 | +  @_alwaysEmitIntoClient | 
|  | 106 | +  @available(*, unavailable, renamed: "dataVault") | 
|  | 107 | +  public static var UF_DATAVAULT: FileFlags { dataVault } | 
|  | 108 | + | 
|  | 109 | +  /// The file or directory is not intended to be displayed to the user. Modifiable by file owner or super-user. | 
|  | 110 | +  /// | 
|  | 111 | +  /// The corresponding C constant is `UF_HIDDEN` | 
|  | 112 | +  @_alwaysEmitIntoClient | 
|  | 113 | +  public static var hidden: FileFlags { FileFlags(_UF_HIDDEN) } | 
|  | 114 | + | 
|  | 115 | +  @_alwaysEmitIntoClient | 
|  | 116 | +  @available(*, unavailable, renamed: "hidden") | 
|  | 117 | +  public static var UF_HIDDEN: FileFlags { hidden } | 
|  | 118 | + | 
|  | 119 | +  /// The file has been archived. Only modifiable by the super-user. | 
|  | 120 | +  /// | 
|  | 121 | +  /// The corresponding C constant is `SF_ARCHIVED` | 
|  | 122 | +  @_alwaysEmitIntoClient | 
|  | 123 | +  public static var superUserArchived: FileFlags { FileFlags(_SF_ARCHIVED) } | 
|  | 124 | + | 
|  | 125 | +  @_alwaysEmitIntoClient | 
|  | 126 | +  @available(*, unavailable, renamed: "superUserArchived") | 
|  | 127 | +  public static var SF_ARCHIVED: FileFlags { superUserArchived } | 
|  | 128 | + | 
|  | 129 | +  /// The file may not be changed. Only modifiable by the super-user. | 
|  | 130 | +  /// | 
|  | 131 | +  /// The corresponding C constant is `SF_IMMUTABLE` | 
|  | 132 | +  @_alwaysEmitIntoClient | 
|  | 133 | +  public static var superUserImmutable: FileFlags { FileFlags(_SF_IMMUTABLE) } | 
|  | 134 | + | 
|  | 135 | +  @_alwaysEmitIntoClient | 
|  | 136 | +  @available(*, unavailable, renamed: "superUserImmutable") | 
|  | 137 | +  public static var SF_IMMUTABLE: FileFlags { superUserImmutable } | 
|  | 138 | + | 
|  | 139 | +  /// The file may only be appended to. Only modifiable by the super-user. | 
|  | 140 | +  /// | 
|  | 141 | +  /// The corresponding C constant is `SF_APPEND` | 
|  | 142 | +  @_alwaysEmitIntoClient | 
|  | 143 | +  public static var superUserAppend: FileFlags { FileFlags(_SF_APPEND) } | 
|  | 144 | + | 
|  | 145 | +  @_alwaysEmitIntoClient | 
|  | 146 | +  @available(*, unavailable, renamed: "superUserAppend") | 
|  | 147 | +  public static var SF_APPEND: FileFlags { superUserAppend } | 
|  | 148 | + | 
|  | 149 | +  /// The file requires entitlement required for reading and writing. Only modifiable by the super-user. | 
|  | 150 | +  /// | 
|  | 151 | +  /// The corresponding C constant is `SF_RESTRICTED` | 
|  | 152 | +  @_alwaysEmitIntoClient | 
|  | 153 | +  public static var superUserRestricted: FileFlags { FileFlags(_SF_RESTRICTED) } | 
|  | 154 | + | 
|  | 155 | +  @_alwaysEmitIntoClient | 
|  | 156 | +  @available(*, unavailable, renamed: "superUserRestricted") | 
|  | 157 | +  public static var SF_RESTRICTED: FileFlags { superUserRestricted } | 
|  | 158 | + | 
|  | 159 | +  /// The file may not be removed, renamed or mounted on. Only modifiable by the super-user. | 
|  | 160 | +  /// | 
|  | 161 | +  /// The corresponding C constant is `SF_NOUNLINK` | 
|  | 162 | +  @_alwaysEmitIntoClient | 
|  | 163 | +  public static var superUserNoUnlink: FileFlags { FileFlags(_SF_NOUNLINK) } | 
|  | 164 | + | 
|  | 165 | +  @_alwaysEmitIntoClient | 
|  | 166 | +  @available(*, unavailable, renamed: "superUserNoUnlink") | 
|  | 167 | +  public static var SF_NOUNLINK: FileFlags { superUserNoUnlink } | 
|  | 168 | + | 
|  | 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 | 
|  | 180 | + | 
|  | 181 | +  /// The file is a firmlink. Only modifiable by the super-user. | 
|  | 182 | +  /// | 
|  | 183 | +  /// The corresponding C constant is `SF_FIRMLINK` | 
|  | 184 | +  @_alwaysEmitIntoClient | 
|  | 185 | +  public static var superUserFirmlink: FileFlags { FileFlags(_SF_FIRMLINK) } | 
|  | 186 | + | 
|  | 187 | +  @_alwaysEmitIntoClient | 
|  | 188 | +  @available(*, unavailable, renamed: "superUserFirmlink") | 
|  | 189 | +  public static var SF_FIRMLINK: FileFlags { superUserFirmlink } | 
|  | 190 | + | 
|  | 191 | +  /// The file is a dataless placeholder. The system will attempt to materialize it when accessed according to the dataless file materialization policy of the accessing thread or process. Cannot be modified in user-space. | 
|  | 192 | +  /// | 
|  | 193 | +  /// The corresponding C constant is `SF_DATALESS` | 
|  | 194 | +  @_alwaysEmitIntoClient | 
|  | 195 | +  public static var kernelDataless: FileFlags { FileFlags(_SF_DATALESS) } | 
|  | 196 | + | 
|  | 197 | +  @_alwaysEmitIntoClient | 
|  | 198 | +  @available(*, unavailable, renamed: "kernelDataless") | 
|  | 199 | +  public static var SF_DATALESS: FileFlags { kernelDataless } | 
|  | 200 | +} | 
|  | 201 | + | 
|  | 202 | +#endif | 
0 commit comments