Skip to content

Commit 427374a

Browse files
committed
Update LocalFS to use FileManager for all operations
LocalFS was using some posix APIs (stat, mkdir, chmod, chown, etc) with some being used in Windows which mean long filenames would fail in some cases, this cleans that up making all platforms that same
1 parent caf6b9f commit 427374a

File tree

10 files changed

+235
-358
lines changed

10 files changed

+235
-358
lines changed

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public final class SwiftCommandOutputParser: TaskOutputParser {
526526
serializedDiagnosticsPaths.filter { path in
527527
// rdar://91295617 (Swift produces empty serialized diagnostics if there are none which is not parseable by clang_loadDiagnostics)
528528
do {
529-
return try fs.exists(path) && fs.getFileInfo(path).statBuf.st_size > 0
529+
return try fs.exists(path) && fs.getFileInfo(path).size > 0
530530
} catch {
531531
return false
532532
}

Sources/SWBLLBuild/LowLevelBuildSystem.swift

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
public import SWBUtil
14-
#if os(Windows)
15-
private import SWBLibc
16-
#else
1714
public import SWBLibc
18-
#endif
1915

2016
// Re-export all APIs from llbuild bindings.
2117
@_exported public import llbuild
@@ -25,7 +21,34 @@ public import SWBLibc
2521
#endif
2622

2723
// Filesystem adaptors for SWBLLBuild.FileSystem.
28-
extension SWBUtil.FileInfo: SWBLLBuild.FileInfo {}
24+
extension SWBUtil.FileInfo: SWBLLBuild.FileInfo {
25+
26+
public init(_ statBuf: stat) {
27+
// This should be remove from llbuild FileInfo protocol as it just not needed, would also be nice to remove the stat requirement too.
28+
preconditionFailure()
29+
}
30+
31+
public var statBuf: stat {
32+
var statBuf: stat = stat()
33+
34+
statBuf.st_dev = numericCast(self.deviceID)
35+
statBuf.st_ino = numericCast(self.iNode)
36+
statBuf.st_mode = numericCast(self.permissions)
37+
statBuf.st_size = numericCast(self.size)
38+
#if canImport(Darwin)
39+
statBuf.st_mtimespec.tv_sec = numericCast(self.modificationTimestamp)
40+
statBuf.st_mtimespec.tv_nsec = self.modificationNanoseconds
41+
#elseif os(Windows)
42+
statBuf.st_mtime = self.modificationTimestamp
43+
#elseif canImport(Glibc) || canImport(Musl) || canImport(Android)
44+
statBuf.st_mtim.tv_sec = numericCast(self.modificationTimestamp)
45+
statBuf.st_mtim.tv_nsec = self.modificationNanoseconds
46+
#else
47+
#error("Not implemented for this platform")
48+
#endif
49+
return statBuf
50+
}
51+
}
2952

3053
public final class FileSystemImpl: FileSystem {
3154

Sources/SWBTaskExecution/TaskActions/ODRAssetPackManifestTaskAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fileprivate extension FSProxy {
108108

109109
try traverse(path) { subPath -> Void in
110110
let info = try getLinkFileInfo(subPath)
111-
uncompressedSize += Int(info.statBuf.st_size)
111+
uncompressedSize += Int(info.size)
112112
newestModTime = max(newestModTime, info.modificationDate)
113113
}
114114

0 commit comments

Comments
 (0)