@@ -195,52 +195,50 @@ extension SourceFileSyntax {
195195 }
196196}
197197
198- #if !os(WASI)
199- /// A ``PackageFileLoader`` adapter for local file system.
200- public struct LocalFileLoader : PackageFileLoader {
201- public typealias FilePath = String
198+ /// A ``PackageFileLoader`` adapter for local file system.
199+ public struct LocalFileLoader : PackageFileLoader {
200+ public typealias FilePath = String
202201
203- let fileManager : FileManager
202+ let fileManager : FileManager
204203
205- public init ( fileManager: FileManager = . default) {
206- self . fileManager = fileManager
207- }
204+ public init ( fileManager: FileManager = . default) {
205+ self . fileManager = fileManager
206+ }
208207
209- enum Error : Swift . Error {
210- case failedToLoadFile( FilePath )
211- }
208+ enum Error : Swift . Error {
209+ case failedToLoadFile( FilePath )
210+ }
212211
213- private func isDirectory( filePath: String ) -> Bool {
214- var isDirectory : ObjCBool = false
215- let exists = fileManager. fileExists ( atPath: filePath, isDirectory: & isDirectory)
216- return exists && isDirectory. boolValue
217- }
212+ private func isDirectory( filePath: String ) -> Bool {
213+ var isDirectory : ObjCBool = false
214+ let exists = fileManager. fileExists ( atPath: filePath, isDirectory: & isDirectory)
215+ return exists && isDirectory. boolValue
216+ }
218217
219- public func contentsOfWITFile( at filePath: String ) throws -> String {
220- guard let bytes = fileManager. contents ( atPath: filePath) else {
221- throw Error . failedToLoadFile ( filePath)
222- }
223- return String ( decoding: bytes, as: UTF8 . self)
218+ public func contentsOfWITFile( at filePath: String ) throws -> String {
219+ guard let bytes = fileManager. contents ( atPath: filePath) else {
220+ throw Error . failedToLoadFile ( filePath)
224221 }
222+ return String ( decoding: bytes, as: UTF8 . self)
223+ }
225224
226- public func packageFiles( in packageDirectory: String ) throws -> [ String ] {
227- let dirURL = URL ( fileURLWithPath: packageDirectory)
228- return try fileManager. contentsOfDirectory ( atPath: packageDirectory) . filter { fileName in
229- return fileName. hasSuffix ( " .wit " )
230- && {
231- let filePath = dirURL. appendingPathComponent ( fileName)
232- return !isDirectory( filePath: filePath. path)
233- } ( )
234- }
235- . map { dirURL. appendingPathComponent ( $0) . path }
225+ public func packageFiles( in packageDirectory: String ) throws -> [ String ] {
226+ let dirURL = URL ( fileURLWithPath: packageDirectory)
227+ return try fileManager. contentsOfDirectory ( atPath: packageDirectory) . filter { fileName in
228+ return fileName. hasSuffix ( " .wit " )
229+ && {
230+ let filePath = dirURL. appendingPathComponent ( fileName)
231+ return !isDirectory( filePath: filePath. path)
232+ } ( )
236233 }
234+ . map { dirURL. appendingPathComponent ( $0) . path }
235+ }
237236
238- public func dependencyDirectories( from packageDirectory: String ) throws -> [ String ] {
239- let dirURL = URL ( fileURLWithPath: packageDirectory)
240- let depsDir = dirURL. appendingPathComponent ( " deps " )
241- guard isDirectory ( filePath: depsDir. path) else { return [ ] }
242- return try fileManager. contentsOfDirectory ( atPath: depsDir. path)
243- }
237+ public func dependencyDirectories( from packageDirectory: String ) throws -> [ String ] {
238+ let dirURL = URL ( fileURLWithPath: packageDirectory)
239+ let depsDir = dirURL. appendingPathComponent ( " deps " )
240+ guard isDirectory ( filePath: depsDir. path) else { return [ ] }
241+ return try fileManager. contentsOfDirectory ( atPath: depsDir. path)
244242 }
243+ }
245244
246- #endif
0 commit comments