Skip to content

Commit

Permalink
Merge pull request #1 from Faire/lucas-fix-ascii-parsing
Browse files Browse the repository at this point in the history
fix ascii parsing
  • Loading branch information
0xLucasMarcal authored Nov 27, 2024
2 parents faf4b52 + 1659f0b commit 460c167
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 52 deletions.
96 changes: 47 additions & 49 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
{
"object": {
"pins": [
{
"package": "CryptoSwift",
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
"state": {
"branch": null,
"revision": "e2bc81be54d71d566a52ca17c3983d141c30aa70",
"version": "1.3.3"
}
},
{
"package": "Gzip",
"repositoryURL": "https://github.com/1024jp/GzipSwift",
"state": {
"branch": null,
"revision": "ba0b6cb51cc6202f896e469b87d2889a46b10d1b",
"version": "5.1.1"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version": "1.0.1"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version": "0.10.1"
}
},
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "fddd1c00396eed152c45a46bea9f47b98e59301d",
"version": "1.2.0"
}
"pins" : [
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "32f641cf24fc7abc1c591a2025e9f2f572648b0f",
"version" : "1.7.2"
}
]
},
"version": 1
},
{
"identity" : "gzipswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/1024jp/GzipSwift",
"state" : {
"revision" : "7a7f17761c76a932662ab77028a4329f67d645a4",
"version" : "5.2.0"
}
},
{
"identity" : "pathkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/PathKit.git",
"state" : {
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version" : "1.0.1"
}
},
{
"identity" : "spectre",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Spectre.git",
"state" : {
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
"version" : "1.2.0"
}
}
],
"version" : 2
}
12 changes: 9 additions & 3 deletions Sources/XCLogParser/loglocation/LogLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ public struct LogLoader {
do {
let data = try Data(contentsOf: url)
let unzipped = try data.gunzipped()
guard let contents = String(data: unzipped, encoding: .ascii) else {
throw LogError.readingFile(url.path)
let contentString: String? = unzipped.withUnsafeBytes { pointer in
guard let charPointer = pointer.assumingMemoryBound(to: CChar.self).baseAddress else {
return nil
}
return String(cString: charPointer, encoding: .ascii)
}
return contents
guard let content = contentString else {
throw LogError.invalidFile(url.path)
}
return content
} catch {
throw LogError.invalidFile(url.path)
}
Expand Down

0 comments on commit 460c167

Please sign in to comment.