From 0bfb82372303d75bbc4970bd75581168ba22bdbb Mon Sep 17 00:00:00 2001 From: Marc Boudou Date: Wed, 24 Feb 2021 13:49:34 +0100 Subject: [PATCH] Open first app group folder --- ControlRoom/Controllers/Application.swift | 3 +++ ControlRoom/Controllers/SimCtl+Types.swift | 2 ++ .../Simulator UI/ControlScreens/AppView/AppView.swift | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/ControlRoom/Controllers/Application.swift b/ControlRoom/Controllers/Application.swift index 356c495..673d019 100644 --- a/ControlRoom/Controllers/Application.swift +++ b/ControlRoom/Controllers/Application.swift @@ -18,6 +18,7 @@ struct Application: Hashable, Comparable { let buildNumber: String let imageURLs: [URL]? let dataFolderURL: URL? + let firstAppGroupFolderURL: URL? let bundleURL: URL? static let `default` = Application() @@ -35,6 +36,7 @@ struct Application: Hashable, Comparable { buildNumber = "" imageURLs = nil dataFolderURL = nil + firstAppGroupFolderURL = nil bundleURL = nil } @@ -56,6 +58,7 @@ struct Application: Hashable, Comparable { .compactMap { Bundle(url: url)?.urlForImageResource($0) } dataFolderURL = URL(string: application.dataFolderPath ?? "") + firstAppGroupFolderURL = URL(string: application.appGroupsFolderPaths?.first?.value ?? "") bundleURL = URL(string: application.bundlePath) } diff --git a/ControlRoom/Controllers/SimCtl+Types.swift b/ControlRoom/Controllers/SimCtl+Types.swift index 645a933..b4cda1f 100644 --- a/ControlRoom/Controllers/SimCtl+Types.swift +++ b/ControlRoom/Controllers/SimCtl+Types.swift @@ -144,6 +144,7 @@ extension SimCtl { let displayName: String let bundlePath: String let dataFolderPath: String? + let appGroupsFolderPaths: [String: String]? } } @@ -155,5 +156,6 @@ extension SimCtl.Application { case displayName = "CFBundleDisplayName" case bundlePath = "Bundle" case dataFolderPath = "DataContainer" + case appGroupsFolderPaths = "GroupContainers" } } diff --git a/ControlRoom/Simulator UI/ControlScreens/AppView/AppView.swift b/ControlRoom/Simulator UI/ControlScreens/AppView/AppView.swift index 50bd6c1..f3f9690 100644 --- a/ControlRoom/Simulator UI/ControlScreens/AppView/AppView.swift +++ b/ControlRoom/Simulator UI/ControlScreens/AppView/AppView.swift @@ -78,6 +78,8 @@ struct AppView: View { Menu { Button("Open data folder", action: openDataFolder) .disabled(selectedApplication.dataFolderURL == nil) + Button("Open first app group folder", action: openFirstAppGroupFolder) + .disabled(selectedApplication.firstAppGroupFolderURL == nil) Button("Open app bundle", action: openAppBundle) .disabled(selectedApplication.bundleURL == nil) @@ -165,6 +167,12 @@ struct AppView: View { NSWorkspace.shared.activateFileViewerSelecting([dataFolderURL]) } + /// Reveals the first app group's container directory in Finder. + func openFirstAppGroupFolder() { + guard let firstAppGroupFolderURL = selectedApplication.firstAppGroupFolderURL else { return } + NSWorkspace.shared.activateFileViewerSelecting([firstAppGroupFolderURL]) + } + /// Reveals the app's bundle directory in Finder. func openAppBundle() { guard