@@ -137,6 +137,13 @@ public enum FileMode: Sendable {
137
137
}
138
138
}
139
139
140
+ /// Extended file system attributes that can applied to a given file path. See also ``FileSystem/hasAttribute(_:_:)``.
141
+ public enum FileSystemAttribute : String {
142
+ #if canImport(Darwin)
143
+ case quarantine = " com.apple.quarantine "
144
+ #endif
145
+ }
146
+
140
147
// FIXME: Design an asynchronous story?
141
148
//
142
149
/// Abstracted access to file system operations.
@@ -171,7 +178,7 @@ public protocol FileSystem: Sendable {
171
178
172
179
/// Returns `true` if a given path has an attribute with a given name applied when file system supports this
173
180
/// attribute. Returns `false` if such attribute is not applied or it isn't supported.
174
- func hasAttribute( name: String , _ path: AbsolutePath ) -> Bool
181
+ func hasAttribute( _ name: FileSystemAttribute , _ path: AbsolutePath ) -> Bool
175
182
176
183
// FIXME: Actual file system interfaces will allow more efficient access to
177
184
// more data than just the name here.
@@ -306,7 +313,7 @@ public extension FileSystem {
306
313
throw FileSystemError ( . unsupported, path)
307
314
}
308
315
309
- func hasAttribute( name: String , _ path: AbsolutePath ) -> Bool { false }
316
+ func hasAttribute( _ name: FileSystemAttribute , _ path: AbsolutePath ) -> Bool { false }
310
317
}
311
318
312
319
/// Concrete FileSystem implementation which communicates with the local file system.
@@ -355,9 +362,9 @@ private struct LocalFileSystem: FileSystem {
355
362
return FileInfo ( attrs)
356
363
}
357
364
358
- func hasAttribute( name: String , _ path: AbsolutePath ) -> Bool {
365
+ func hasAttribute( _ name: FileSystemAttribute , _ path: AbsolutePath ) -> Bool {
359
366
#if canImport(Darwin)
360
- let bufLength = getxattr ( path. pathString, name, nil , 0 , 0 , 0 )
367
+ let bufLength = getxattr ( path. pathString, name. rawValue , nil , 0 , 0 , 0 )
361
368
362
369
return bufLength > 0
363
370
#else
0 commit comments