Skip to content

Commit 2f9c8cc

Browse files
Fix swift-foundation build
swiftlang/swift-foundation#1094
1 parent 1b03388 commit 2f9c8cc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From cc9d6a3535122542a28f3cf8eb93feb95e05b0f5 Mon Sep 17 00:00:00 2001
2+
From: Yuta Saito <[email protected]>
3+
Date: Fri, 13 Dec 2024 16:09:59 +0000
4+
Subject: [PATCH] Fix WASI build of `_copyDirectoryMetadata`
5+
6+
Extended attributes don't exist in WASI, so we need to exclude the use
7+
of xattr-related APIs including `flistxattr`.
8+
---
9+
Sources/FoundationEssentials/FileManager/FileOperations.swift | 2 ++
10+
1 file changed, 2 insertions(+)
11+
12+
diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift
13+
index 418f5cfb..9567f65d 100644
14+
--- a/Sources/FoundationEssentials/FileManager/FileOperations.swift
15+
+++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift
16+
@@ -951,6 +951,7 @@ enum _FileOperations {
17+
18+
#if !canImport(Darwin)
19+
private static func _copyDirectoryMetadata(srcFD: CInt, srcPath: @autoclosure () -> String, dstFD: CInt, dstPath: @autoclosure () -> String, delegate: some LinkOrCopyDelegate) throws {
20+
+ #if !os(WASI)
21+
// Copy extended attributes
22+
var size = flistxattr(srcFD, nil, 0)
23+
if size > 0 {
24+
@@ -976,6 +977,7 @@ enum _FileOperations {
25+
}
26+
}
27+
}
28+
+ #endif
29+
var statInfo = stat()
30+
if fstat(srcFD, &statInfo) == 0 {
31+
// Copy owner/group

0 commit comments

Comments
 (0)