Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Commit

Permalink
Improve docs about TAR/ZIP command output
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed May 20, 2020
1 parent 0c8dca8 commit e34a99e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions QLPlugin/Views/Previews/TARPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ class TARPreview: Preview {
private func parseTARFiles(lines: String) -> FileTree {
let fileTree = FileTree()

// Content lines: "-rw-r--r-- 0 user staff 642 Dec 29 2018 my-tar/file.ext"
// - "-" as first character indicates a file, "d" a directory
// - Digits before date indicate number of bytes
// List entry format: "-rw-r--r-- 0 user staff 642 Dec 29 2018 my-tar/file.ext"
// - Column 1: Permissions ("-" as first character indicates a file, "d" a directory)
// - Column 5: File size in bytes
// - Columns 6-8: Date modified
// - Column 9: File path
let fileMatches = lines.matchRegex(regex: filesRegex)
for fileMatch in fileMatches {
let permissions = fileMatch[1]
Expand Down
8 changes: 5 additions & 3 deletions QLPlugin/Views/Previews/ZIPPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ class ZIPPreview: Preview {
let fileTree = FileTree()
let linesSplit = lines.split(separator: "\n")

// Content lines: "drwxr-xr-x 2.0 unx 0 bx stor 20-Jan-13 19:38 my-zip/dir/"
// - "-" as first character indicates a file, "d" a directory
// - "0 bx" indicates the number of bytes
// List entry format: "drwxr-xr-x 2.0 unx 0 bx stor 20-Jan-13 19:38 my-zip/dir/"
// - Column 1: Permissions ("-" as first character indicates a file, "d" a directory)
// - Column 4: File size in bytes
// - Columns 7-8: Date modified
// - Column 9: File path
let filesString = linesSplit[2 ..< linesSplit.count - 1].joined(separator: "\n")
let fileMatches = filesString.matchRegex(regex: filesRegex)
for fileMatch in fileMatches {
Expand Down

0 comments on commit e34a99e

Please sign in to comment.