Files
SwiftLint/Source/SwiftLintFramework/Extensions/NSFileManager+SwiftLint.swift
T
JP Simard 1866edae77 adjust access control levels for many APIs in SwiftLintFramework
this is done in an effort to stabilize the API for SwiftLint 1.0.
2016-02-10 17:26:06 -08:00

33 lines
960 B
Swift

//
// NSFileManager+SwiftLint.swift
// SwiftLint
//
// Created by JP Simard on 5/28/15.
// Copyright (c) 2015 Realm. All rights reserved.
//
import Foundation
extension NSFileManager {
internal func filesToLintAtPath(path: String) -> [String] {
let absolutePath = path.absolutePathStandardized()
var isDirectory: ObjCBool = false
guard fileExistsAtPath(absolutePath, isDirectory: &isDirectory) else {
return []
}
if isDirectory {
do {
return try subpathsOfDirectoryAtPath(absolutePath)
.map((absolutePath as NSString).stringByAppendingPathComponent).filter {
$0.isSwiftFile()
}
} catch {
fatalError("Couldn't find files in \(absolutePath): \(error)")
}
} else if absolutePath.isSwiftFile() {
return [absolutePath]
}
return []
}
}