Skip to content

Commit

Permalink
Update FileManager+Source.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rismay-luassat committed Jun 25, 2024
1 parent 4dccc1c commit 03e8024
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/WrkstrmFoundation/Extensions/FileManager+Source.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Foundation
// MARK: - FileManager + Localization Searches

extension FileManager {

/// Retrieves all source files from the specified directories.
///
/// This function iterates over each directory, listing all the source files contained within.
Expand All @@ -21,7 +20,7 @@ extension FileManager {
/// - Returns: An array of strings representing the paths of all source files found.
public func allSourceFiles(in directories: [String]) -> [String] {
var files: [String] = []
directories.forEach { directory in
for directory in directories {
if let sourceFiles = try? subpathsOfDirectory(atPath: directory).sourceFiles {
files += sourceFiles.map { "\(directory)/\($0)" }
}
Expand All @@ -35,10 +34,11 @@ extension FileManager {
/// Useful for collecting all NIB files in a project for localization or analysis purposes.
///
/// - Parameter directories: An array of directory paths to search within.
/// - Returns: An optional array of strings representing the paths of all NIB files found, or `nil` if none are found.
/// - Returns: An optional array of strings representing the paths of all NIB files found, or
/// `nil` if none are found.
public func allNibFiles(in directories: [String]) -> [String]? {
var files: [String] = []
directories.forEach { directory in
for directory in directories {
if let nibFiles = try? FileManager.default.subpathsOfDirectory(atPath: directory).nibFiles {
files += nibFiles.map { "\(directory)/\($0)" }
}
Expand All @@ -52,7 +52,8 @@ extension FileManager {
/// tracking changes or determining if a file needs to be updated or replaced.
///
/// - Parameter path: The path of the file for which the modification date is needed.
/// - Returns: An optional `Date` representing the last modification date, or `nil` if it cannot be retrieved.
/// - Returns: An optional `Date` representing the last modification date, or `nil` if it cannot
/// be retrieved.
public func modificationDateForFile(at path: String) -> Date? {
if let attributes = try? attributesOfItem(atPath: path) {
return attributes[FileAttributeKey.modificationDate] as? Date
Expand Down

0 comments on commit 03e8024

Please sign in to comment.