Skip to content

Commit

Permalink
Add support for UTF-8 encoded filenames (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelOteroIFD authored Nov 24, 2021
1 parent ad158d2 commit fcff1f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Light-Swift-Untar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ public extension FileManager {
}

private func name(object: Any, offset: UInt64) -> String {
var name = ""
var nameSize = FileManager.tarNameSize
for i in 0...FileManager.tarNameSize {
let char = String(data: data(object: object, location: offset + FileManager.tarNamePosition + i, length: 1)!, encoding: .ascii)!
if (char == "\0") {
return name
nameSize = i
break
}
name += char
}
return name
return String(data: data(object: object, location: offset + FileManager.tarNamePosition, length: nameSize)!, encoding: .utf8)!
}

private func size(object: Any, offset: UInt64) -> UInt64 {
Expand Down

0 comments on commit fcff1f1

Please sign in to comment.