diff --git a/Zockerhoehle/ICloudManager.swift b/Zockerhoehle/ICloudManager.swift index 4f5fbf7..8cf5db5 100644 --- a/Zockerhoehle/ICloudManager.swift +++ b/Zockerhoehle/ICloudManager.swift @@ -39,7 +39,18 @@ class ICloudManager { }catch { return .none } + } + + static public func inICloudContainer(url : URL?) -> Bool { + guard let url = url else { return false } + for component in url.pathComponents { + if relative_seperator.count > 0 && component == relative_seperator[0] { + return true + } + } + + return false } private init() { diff --git a/Zockerhoehle/Views/ConsoleAllView.swift b/Zockerhoehle/Views/ConsoleAllView.swift index 646aab7..08cfad7 100644 --- a/Zockerhoehle/Views/ConsoleAllView.swift +++ b/Zockerhoehle/Views/ConsoleAllView.swift @@ -70,7 +70,7 @@ struct ModalAddConsoleToLibrary : View { let selectedFile : URL = try result.get().first! //It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder - if (FileManager.default.isUbiquitousItem(at: selectedFile)) { + if (ICloudManager.inICloudContainer(url: selectedFile)) { self.modalConsoleLogoICloudPath = ICloudManager.relativePathFrom(url: selectedFile) print("Selected Image in iCloud Path \(self.modalConsoleLogoICloudPath ?? "n/a")") diff --git a/Zockerhoehle/Views/ConsoleEditView.swift b/Zockerhoehle/Views/ConsoleEditView.swift index bad62ca..b933858 100644 --- a/Zockerhoehle/Views/ConsoleEditView.swift +++ b/Zockerhoehle/Views/ConsoleEditView.swift @@ -39,7 +39,7 @@ struct ConsoleEditView: View { let selectedFile : URL = try result.get().first! //It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder - if (FileManager.default.isUbiquitousItem(at: selectedFile)) { + if (ICloudManager.inICloudContainer(url: selectedFile)) { console.logo_icloud_path = ICloudManager.relativePathFrom(url: selectedFile) print("Selected Image in iCloud Path \(console.logo_icloud_path ?? "n/a")") diff --git a/Zockerhoehle/Views/GameDetailView.swift b/Zockerhoehle/Views/GameDetailView.swift index 9e61710..4695119 100644 --- a/Zockerhoehle/Views/GameDetailView.swift +++ b/Zockerhoehle/Views/GameDetailView.swift @@ -110,7 +110,7 @@ struct GameDetailView : View { let selectedFile : URL = try result.get().first! //It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder - if (FileManager.default.isUbiquitousItem(at: selectedFile)) { + if (ICloudManager.inICloudContainer(url: selectedFile)) { game.cover_icloud_path = ICloudManager.relativePathFrom(url: selectedFile) print("Selected Image in iCloud Path \(game.cover_icloud_path ?? "n/a")") diff --git a/Zockerhoehle/Views/GameSeriesAllView.swift b/Zockerhoehle/Views/GameSeriesAllView.swift index 2472b9b..12d8e27 100644 --- a/Zockerhoehle/Views/GameSeriesAllView.swift +++ b/Zockerhoehle/Views/GameSeriesAllView.swift @@ -47,7 +47,7 @@ struct ModalAddGameSeries : View { let selectedFile : URL = try result.get().first! //It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder - if (FileManager.default.isUbiquitousItem(at: selectedFile)) { + if (ICloudManager.inICloudContainer(url: selectedFile)) { self.modalGameSeriesCover = ICloudManager.relativePathFrom(url: selectedFile) print("Selected Image in iCloud Path \(self.modalGameSeriesCover ?? "n/a")") diff --git a/Zockerhoehle/Views/GameSeriesEditView.swift b/Zockerhoehle/Views/GameSeriesEditView.swift index 67383c9..4943c3c 100644 --- a/Zockerhoehle/Views/GameSeriesEditView.swift +++ b/Zockerhoehle/Views/GameSeriesEditView.swift @@ -36,7 +36,7 @@ struct GameSeriesEditView: View { let selectedFile : URL = try result.get().first! //It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder - if (FileManager.default.isUbiquitousItem(at: selectedFile)) { + if (ICloudManager.inICloudContainer(url: selectedFile)) { gameSeries.cover_icloud_path = ICloudManager.relativePathFrom(url: selectedFile) print("Selected Image in iCloud Path \(gameSeries.cover_icloud_path ?? "n/a")")