Skip to content
Open
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
10 changes: 9 additions & 1 deletion Sources/Tarscape/KBFileAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ public struct KBFileAttributes {
self.fileType = isAlias ? .alias : FileType(mode: fileStat.st_mode)

// File size.
self.fileSize = Int(fileStat.st_size)
// Some directories and links return a size using stat (return nil with FileManager),
// since we never write any data for non "normalFile" adding here the size
// will produce a bad header that will cause issues when parsed and data corruption.
if self.fileType == .file {
self.fileSize = Int(fileStat.st_size)
}
else {
self.fileSize = 0
}

// Modification date.
let modTimeSpec = fileStat.st_mtimespec
Expand Down