Skip to content

Commit

Permalink
Merge pull request #2 from etsy/ugonzalez/adding-ascii-fix-to-fork
Browse files Browse the repository at this point in the history
Updating ascii parsing
  • Loading branch information
UrielHernandez26 authored Dec 16, 2024
2 parents 251e44b + ef1f0e5 commit e99f7f2
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit e99f7f2

Please sign in to comment.