Skip to content

Is it possible to TAR a directory? #20

Closed Answered by LebJe
LebJe asked this question in Q&A
Discussion options

You must be logged in to vote

@tsolomko Thank you for the solution. My code now looks like this:

import SWCompression
import Foundation


// From https://github.com/tsolomko/SWCompression/blob/4fa4adcf5bbf263388edcbf2631987039a84b389/Sources/swcomp/Containers/TarCommand.swift#L101
func createEntries(_ inputPath: String) throws -> [TarEntry] {
	let inputURL = URL(fileURLWithPath: inputPath)
	let fileManager = FileManager.default
	
	...
}


let entries = try createEntries("test-folder")

let data = try GzipArchive.archive(data: try TarContainer.create(from: entries))

try data.write(to: URL(fileURLWithPath: "test-folder.tar.gz"))

By "invalid directory" I meant there was nothing in the unarchived directory even though th…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tsolomko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #16 on March 25, 2021 16:49.