Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martenrebane committed Jun 12, 2024
1 parent 03db08c commit bfc5209
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
xcode:
- 15.2
- 15.4
platform:
- iOS
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
xcode:
- 15.2
- 15.4
platform:
- iOS
language: [ 'swift' ]
Expand Down
36 changes: 26 additions & 10 deletions MoppApp/MoppApp/Extensions/URL+Additions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,36 @@ extension URL {
}

func getValidPath() -> URL? {
guard let appDirectoryURL = FileManager.default.urls(for: .applicationDirectory, in: .userDomainMask).first else {
return nil
}

guard let subdirectoryURLs = try? FileManager.default.contentsOfDirectory(at: appDirectoryURL, includingPropertiesForKeys: nil, options: .skipsHiddenFiles) else {
return nil
let directories: [FileManager.SearchPathDirectory] = [
.documentDirectory,
.downloadsDirectory,
.userDirectory,
.libraryDirectory,
]

let currentURL = URL(fileURLWithPath: self.path).resolvingSymlinksInPath()
let currentURLPath = currentURL.path

for directory in directories {
guard let directoryURL = FileManager.default.urls(for: directory, in: .userDomainMask).first else {
continue
}

guard let subdirectoryURLs = try? FileManager.default.contentsOfDirectory(at: directoryURL, includingPropertiesForKeys: nil, options: .skipsHiddenFiles) else {
continue
}

for subdirectoryURL in subdirectoryURLs {
let subdirectoryFilePath = FilePath(stringLiteral: subdirectoryURL.path)
if (FilePath(stringLiteral: self.path).starts(with: subdirectoryFilePath.lexicallyNormalized())) {
return URL(fileURLWithPath: subdirectoryFilePath.description)
let resolvedSubdirectoryURL = subdirectoryURL.resolvingSymlinksInPath()
let resolvedSubdirectoryPath = resolvedSubdirectoryURL.path

if FilePath(stringLiteral: currentURLPath).starts(with: FilePath(stringLiteral: resolvedSubdirectoryPath)) {
return currentURL
}
}
return nil
}

return nil
}

}

0 comments on commit bfc5209

Please sign in to comment.