mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
[swcomp] Correctly extract hard links from TAR containers
Note that creating containers with hard links is still not supported (I do not know how to detect hard links with FileManager).
This commit is contained in:
@@ -106,7 +106,17 @@ func writeFile<T: ContainerEntry>(_ entry: T, _ outputURL: URL, _ verbose: Bool)
|
||||
print("l: \(entryName) -> \(destinationPath!)")
|
||||
}
|
||||
try fileManager.createSymbolicLink(atPath: entryFullURL.path, withDestinationPath: destinationPath!)
|
||||
// We cannot apply attributes to symbolic link.
|
||||
// We cannot apply attributes to symbolic links.
|
||||
return
|
||||
} else if entry.info.type == .hardLink {
|
||||
guard let destinationPath = (entry as? TarEntry)?.info.linkName
|
||||
else { swcompExit(.containerHardLinkDestPath(entryName)) }
|
||||
if verbose {
|
||||
print("hl: \(entryName) -> \(destinationPath)")
|
||||
}
|
||||
// Note that the order of parameters is inversed for hard links.
|
||||
try fileManager.linkItem(atPath: destinationPath, toPath: entryFullURL.path)
|
||||
// We cannot apply attributes to hard links.
|
||||
return
|
||||
} else if entry.info.type == .regular {
|
||||
if verbose {
|
||||
|
||||
@@ -20,6 +20,7 @@ enum SwcompError {
|
||||
case benchmarkCannotGetSubcommandPathWindows
|
||||
case benchmarkCannotAppendToDirectory
|
||||
case containerSymLinkDestPath(String)
|
||||
case containerHardLinkDestPath(String)
|
||||
case containerNoEntryData(String)
|
||||
case containerOutPathExistsNotDir
|
||||
case fileHandleCannotOpen
|
||||
@@ -55,6 +56,8 @@ enum SwcompError {
|
||||
return 207
|
||||
case .containerSymLinkDestPath:
|
||||
return 301
|
||||
case .containerHardLinkDestPath:
|
||||
return 311
|
||||
case .containerNoEntryData:
|
||||
return 302
|
||||
case .containerOutPathExistsNotDir:
|
||||
@@ -83,7 +86,7 @@ enum SwcompError {
|
||||
case .benchmarkSmallIterCount:
|
||||
return "Iteration count, if set, must be not less than 1."
|
||||
case .benchmarkUnknownCompResult:
|
||||
return "Unknown comparison "
|
||||
return "Unknown comparison."
|
||||
case .benchmarkCannotSetup(let benchmark, let input, let error):
|
||||
return "Unable to set up benchmark \(benchmark): input=\(input), error=\(error)."
|
||||
case .benchmarkCannotMeasure(let benchmark, let error):
|
||||
@@ -98,6 +101,8 @@ enum SwcompError {
|
||||
return "Cannot append results to the save path since it is a directory."
|
||||
case .containerSymLinkDestPath(let entryName):
|
||||
return "Unable to get destination path for symbolic link \(entryName)."
|
||||
case .containerHardLinkDestPath(let entryName):
|
||||
return "Unable to get destination path for hard link \(entryName)."
|
||||
case .containerNoEntryData(let entryName):
|
||||
return "Unable to get data for the entry \(entryName)."
|
||||
case .containerOutPathExistsNotDir:
|
||||
|
||||
Reference in New Issue
Block a user