From 5d781d1657f84f21bfeee1054c983a1d02489d3d Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 13 Nov 2017 18:19:25 -0800 Subject: [PATCH] Add method to display contents of file in WebViewWindowController. --- .../RSCore/RSCore/AppKit/WebViewWindowController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift b/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift index 7ce3d4734..943d83702 100644 --- a/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift +++ b/Frameworks/RSCore/RSCore/AppKit/WebViewWindowController.swift @@ -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) + } }