We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 251e44b + ef1f0e5 commit e99f7f2Copy full SHA for e99f7f2
Sources/XCLogParser/loglocation/LogLoader.swift
@@ -26,7 +26,18 @@ public struct LogLoader {
26
do {
27
let data = try Data(contentsOf: url)
28
let unzipped = try data.gunzipped()
29
- guard let contents = String(data: unzipped, encoding: .ascii) else {
+ let string: String? = unzipped.withUnsafeBytes { pointer in
30
+ guard let charPointer = pointer
31
+ .assumingMemoryBound(to: CChar.self)
32
+ .baseAddress
33
+ else {
34
+ return nil
35
+ }
36
+
37
+ return String(cString: charPointer, encoding: .ascii)
38
39
40
+ guard let contents = string else {
41
throw LogError.readingFile(url.path)
42
}
43
return contents
0 commit comments