Skip to content

Commit

Permalink
Create JSONResource.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rismay committed Jun 28, 2024
1 parent 3cfbadf commit af0f10b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/WrkstrmFoundation/JSON/JSONResource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Foundation

enum JSONResource {
static func load(fileName: String) -> Data? {
let currentFileURL = URL(fileURLWithPath: #file)
let currentDirectoryURL = currentFileURL.deletingLastPathComponent()

let fileURL =
currentDirectoryURL
.appendingPathComponent("Resources", isDirectory: true)
.appendingPathComponent(fileName)
.appendingPathExtension("json")

return try? Data(contentsOf: fileURL)
}
}

0 comments on commit af0f10b

Please sign in to comment.