Skip to content

Commit fa43c96

Browse files
authored
Move temporarily relocated FileManager extensions back to their original locations (#1213)
1 parent 2f65d91 commit fa43c96

File tree

3 files changed

+39
-61
lines changed

3 files changed

+39
-61
lines changed

Sources/FoundationEssentials/FileManager/FileManager+Files.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,40 @@ extension stat {
201201
}
202202
}
203203

204+
#if FOUNDATION_FRAMEWORK
205+
extension FileProtectionType {
206+
var intValue: Int32? {
207+
switch self {
208+
case .complete: PROTECTION_CLASS_A
209+
case .init(rawValue: "NSFileProtectionWriteOnly"), .completeUnlessOpen: PROTECTION_CLASS_B
210+
case .init(rawValue: "NSFileProtectionCompleteUntilUserAuthentication"), .completeUntilFirstUserAuthentication: PROTECTION_CLASS_C
211+
case .none: PROTECTION_CLASS_D
212+
#if !os(macOS)
213+
case .completeWhenUserInactive: PROTECTION_CLASS_CX
214+
#endif
215+
default: nil
216+
}
217+
}
218+
219+
init?(intValue value: Int32) {
220+
switch value {
221+
case PROTECTION_CLASS_A: self = .complete
222+
case PROTECTION_CLASS_B: self = .completeUnlessOpen
223+
case PROTECTION_CLASS_C: self = .completeUntilFirstUserAuthentication
224+
case PROTECTION_CLASS_D: self = .none
225+
#if !os(macOS)
226+
case PROTECTION_CLASS_CX: self = .completeWhenUserInactive
227+
#endif
228+
default: return nil
229+
}
230+
}
231+
}
204232
#endif
233+
#endif
234+
235+
extension FileAttributeKey {
236+
fileprivate static var _extendedAttributes: Self { Self("NSFileExtendedAttributes") }
237+
}
205238

206239
extension _FileManagerImpl {
207240
func createFile(

Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ extension stat {
6969
}
7070
#endif
7171

72+
#if FOUNDATION_FRAMEWORK && os(macOS)
73+
extension URLResourceKey {
74+
static var _finderInfoKey: Self { URLResourceKey("_NSURLFinderInfoKey") }
75+
}
76+
#endif
77+
7278
extension _FileManagerImpl {
7379
#if os(macOS) && FOUNDATION_FRAMEWORK
7480
private struct _HFSFinderInfo {

Sources/FoundationEssentials/String/String+Bridging.swift

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -271,65 +271,4 @@ extension BidirectionalCollection where Element == Unicode.Scalar, Index == Stri
271271

272272
}
273273

274-
// START: Workaround for https://github.com/swiftlang/swift/pull/78697
275-
276-
// The extensions below are temporarily relocated to work around a compiler crash.
277-
// Once that crash is resolved, they should be moved back to their original files.
278-
279-
#if !NO_FILESYSTEM
280-
281-
// Relocated from FileManager+Utilities.swift
282-
#if FOUNDATION_FRAMEWORK && os(macOS)
283-
extension URLResourceKey {
284-
static var _finderInfoKey: Self { URLResourceKey("_NSURLFinderInfoKey") }
285-
}
286-
#endif
287-
288-
// Relocated from FileManager+Files.swift
289-
#if FOUNDATION_FRAMEWORK
290-
internal import DarwinPrivate.sys.content_protection
291274
#endif
292-
293-
#if !os(Windows)
294-
#if FOUNDATION_FRAMEWORK
295-
extension FileProtectionType {
296-
var intValue: Int32? {
297-
switch self {
298-
case .complete: PROTECTION_CLASS_A
299-
case .init(rawValue: "NSFileProtectionWriteOnly"), .completeUnlessOpen: PROTECTION_CLASS_B
300-
case .init(rawValue: "NSFileProtectionCompleteUntilUserAuthentication"), .completeUntilFirstUserAuthentication: PROTECTION_CLASS_C
301-
case .none: PROTECTION_CLASS_D
302-
#if !os(macOS)
303-
case .completeWhenUserInactive: PROTECTION_CLASS_CX
304-
#endif
305-
default: nil
306-
}
307-
}
308-
309-
init?(intValue value: Int32) {
310-
switch value {
311-
case PROTECTION_CLASS_A: self = .complete
312-
case PROTECTION_CLASS_B: self = .completeUnlessOpen
313-
case PROTECTION_CLASS_C: self = .completeUntilFirstUserAuthentication
314-
case PROTECTION_CLASS_D: self = .none
315-
#if !os(macOS)
316-
case PROTECTION_CLASS_CX: self = .completeWhenUserInactive
317-
#endif
318-
default: return nil
319-
}
320-
}
321-
}
322-
#endif
323-
#endif
324-
#endif
325-
326-
#endif
327-
328-
#if !NO_FILESYSTEM
329-
// Relocated from FileManager+Files.swift. Originally fileprivate.
330-
extension FileAttributeKey {
331-
internal static var _extendedAttributes: Self { Self("NSFileExtendedAttributes") }
332-
}
333-
#endif
334-
335-
// END: Workaround for https://github.com/swiftlang/swift/pull/78697

0 commit comments

Comments
 (0)