From 6e72fb86942d7a1e727abc2e08d8ef9d4b48f50d Mon Sep 17 00:00:00 2001 From: Cristian A Monterroza Date: Sat, 29 Jun 2024 00:16:24 -0700 Subject: [PATCH] Make load function public. --- Sources/WrkstrmFoundation/JSON/JSONResource.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/WrkstrmFoundation/JSON/JSONResource.swift b/Sources/WrkstrmFoundation/JSON/JSONResource.swift index 67f2187..fdf7235 100644 --- a/Sources/WrkstrmFoundation/JSON/JSONResource.swift +++ b/Sources/WrkstrmFoundation/JSON/JSONResource.swift @@ -11,10 +11,12 @@ extension WrkstrmMain.JSON { /// then attempts to load the file's content as `Data`. /// /// - Parameter fileName: The name of the JSON file to load (without the `.json` extension). + /// - Parameter relativeToFilePath: The relative file path to load the resource from. By default, from + /// the calling file. /// - Returns: The `Data` content of the JSON file if it exists, or `nil` if an error occurs. - static func load(fileName: String) -> Data? { + public static func load(fileName: String, relativeToFilePath file: String = #file) -> Data? { // URL of the current file - let currentFileURL = URL(fileURLWithPath: #file) + let currentFileURL = URL(fileURLWithPath: file) // Directory URL by deleting the last path component from the current file's URL let currentDirectoryURL = currentFileURL.deletingLastPathComponent()