Create 2 Document Types
Name: Tar archive
Identifier: public.tar-archive
Class: $(PRODUCT_MODULE_NAME).Document
Role: Viewer
Name: Gzip tar archive
Identifier: org.gnu.gnu-zip-tar-archive
Class: $(PRODUCT_MODULE_NAME).Document
Role: Viewer
Update read(from:ofType:)
override func read(from url: URL, ofType typeName: String) throws {
// Which file are we getting the zipinfo for?
let filename = url.path
// Prepare a task object
let task = Process()
switch url.pathExtension {
case "tar":
task.launchPath = "/usr/bin/tar"
task.arguments = ["tf", filename]
case "tgz":
task.launchPath = "/usr/bin/tar"
task.arguments = ["tzf", filename]
default:
task.launchPath = "/usr/bin/zipinfo"
task.arguments = ["-1", filename]
}
. . .