Skip to content

Commit

Permalink
Merge pull request twostraws#124 from squall2022/feature/add-open-app…
Browse files Browse the repository at this point in the history
…-group-container-button

Add a button to open the first app group folder
  • Loading branch information
twostraws authored Mar 8, 2021
2 parents d782b14 + 0bfb823 commit 9e3ed69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ControlRoom/Controllers/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -35,6 +36,7 @@ struct Application: Hashable, Comparable {
buildNumber = ""
imageURLs = nil
dataFolderURL = nil
firstAppGroupFolderURL = nil
bundleURL = nil
}

Expand All @@ -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)
}

Expand Down
2 changes: 2 additions & 0 deletions ControlRoom/Controllers/SimCtl+Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ extension SimCtl {
let displayName: String
let bundlePath: String
let dataFolderPath: String?
let appGroupsFolderPaths: [String: String]?
}
}

Expand All @@ -155,5 +156,6 @@ extension SimCtl.Application {
case displayName = "CFBundleDisplayName"
case bundlePath = "Bundle"
case dataFolderPath = "DataContainer"
case appGroupsFolderPaths = "GroupContainers"
}
}
8 changes: 8 additions & 0 deletions ControlRoom/Simulator UI/ControlScreens/AppView/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9e3ed69

Please sign in to comment.