Changed iCloud folder recognition

This commit is contained in:
2021-05-19 08:55:17 +02:00
parent 80491541c2
commit 59fc67b5f0
6 changed files with 16 additions and 5 deletions

View File

@@ -39,7 +39,18 @@ class ICloudManager {
}catch { }catch {
return .none 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() { private init() {

View File

@@ -70,7 +70,7 @@ struct ModalAddConsoleToLibrary : View {
let selectedFile : URL = try result.get().first! let selectedFile : URL = try result.get().first!
//It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder //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) self.modalConsoleLogoICloudPath = ICloudManager.relativePathFrom(url: selectedFile)
print("Selected Image in iCloud Path \(self.modalConsoleLogoICloudPath ?? "n/a")") print("Selected Image in iCloud Path \(self.modalConsoleLogoICloudPath ?? "n/a")")

View File

@@ -39,7 +39,7 @@ struct ConsoleEditView: View {
let selectedFile : URL = try result.get().first! let selectedFile : URL = try result.get().first!
//It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder //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) console.logo_icloud_path = ICloudManager.relativePathFrom(url: selectedFile)
print("Selected Image in iCloud Path \(console.logo_icloud_path ?? "n/a")") print("Selected Image in iCloud Path \(console.logo_icloud_path ?? "n/a")")

View File

@@ -110,7 +110,7 @@ struct GameDetailView : View {
let selectedFile : URL = try result.get().first! let selectedFile : URL = try result.get().first!
//It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder //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) game.cover_icloud_path = ICloudManager.relativePathFrom(url: selectedFile)
print("Selected Image in iCloud Path \(game.cover_icloud_path ?? "n/a")") print("Selected Image in iCloud Path \(game.cover_icloud_path ?? "n/a")")

View File

@@ -47,7 +47,7 @@ struct ModalAddGameSeries : View {
let selectedFile : URL = try result.get().first! let selectedFile : URL = try result.get().first!
//It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder //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) self.modalGameSeriesCover = ICloudManager.relativePathFrom(url: selectedFile)
print("Selected Image in iCloud Path \(self.modalGameSeriesCover ?? "n/a")") print("Selected Image in iCloud Path \(self.modalGameSeriesCover ?? "n/a")")

View File

@@ -36,7 +36,7 @@ struct GameSeriesEditView: View {
let selectedFile : URL = try result.get().first! let selectedFile : URL = try result.get().first!
//It seems that isUbiquitousItem checks if the file is contained in the Apps iCloud folder //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) gameSeries.cover_icloud_path = ICloudManager.relativePathFrom(url: selectedFile)
print("Selected Image in iCloud Path \(gameSeries.cover_icloud_path ?? "n/a")") print("Selected Image in iCloud Path \(gameSeries.cover_icloud_path ?? "n/a")")