Add method to display contents of file in WebViewWindowController.

This commit is contained in:
Brent Simmons 2017-11-13 18:19:25 -08:00
parent 773f660601
commit 5d781d1657

View File

@ -24,4 +24,14 @@ public final class WebViewWindowController: NSWindowController {
window!.title = title
}
public func displayContents(of path: String) {
// We assume there might be images, style sheets, etc. contained by the folder that the file appears in, so we get read access to the parent folder.
let fileURL = URL(fileURLWithPath: path)
let folderURL = fileURL.deletingLastPathComponent()
webview.loadFileURL(fileURL, allowingReadAccessTo: folderURL)
}
}