Skip to content

Commit b4c1c12

Browse files
NKTypeIdentifiersHelper
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
1 parent d82e7ac commit b4c1c12

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Sources/NextcloudKit/TypeIdentifiers/NKTypeIdentifiers.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,42 @@ public actor NKTypeIdentifiers {
8181
return (mimeType: mimeType, classFile: classFile, iconName: iconName, typeIdentifier: typeIdentifier, fileNameWithoutExt: fileNameWithoutExt, ext: ext)
8282
}
8383
}
84+
85+
public final class NKTypeIdentifiersHelper {
86+
private let actor: NKTypeIdentifiers
87+
88+
public init(actor: NKTypeIdentifiers) {
89+
self.actor = actor
90+
}
91+
92+
public func getInternalTypeSync(fileName: String, mimeType: String, directory: Bool, account: String) -> (mimeType: String,
93+
classFile: String,
94+
iconName: String,
95+
typeIdentifier: String,
96+
fileNameWithoutExt: String,
97+
ext: String) {
98+
var result: (
99+
mimeType: String,
100+
classFile: String,
101+
iconName: String,
102+
typeIdentifier: String,
103+
fileNameWithoutExt: String,
104+
ext: String
105+
)!
106+
107+
let semaphore = DispatchSemaphore(value: 0)
108+
109+
Task {
110+
result = await actor.getInternalType(
111+
fileName: fileName,
112+
mimeType: mimeType,
113+
directory: directory,
114+
account: account
115+
)
116+
semaphore.signal()
117+
}
118+
119+
semaphore.wait()
120+
return result
121+
}
122+
}

0 commit comments

Comments
 (0)