Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Sources/XCLogParser/loglocation/LogLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ public struct LogLoader {
do {
let data = try Data(contentsOf: url)
let unzipped = try data.gunzipped()
guard let contents = String(data: unzipped, encoding: .ascii) else {
let string: String? = unzipped.withUnsafeBytes { pointer in
guard let charPointer = pointer
.assumingMemoryBound(to: CChar.self)
.baseAddress
else {
return nil
}

return String(cString: charPointer, encoding: .ascii)
}

guard let contents = string else {
throw LogError.readingFile(url.path)
}
return contents
Expand Down
Loading