From 6e49741528ff56e9e722a3ea6afd6c708ecef5ff Mon Sep 17 00:00:00 2001
From: Mooffie <mooffie@gmail.com>
Date: Mon, 19 Dec 2016 02:04:10 +0200
Subject: [PATCH 1/6] Ticket #2707: extfs: u7z: make the code more readable.
---
src/vfs/extfs/helpers/u7z | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/vfs/extfs/helpers/u7z b/src/vfs/extfs/helpers/u7z
index 22e9f27..8270a20 100755
a
|
b
|
mcu7zip_list () |
23 | 23 | { |
24 | 24 | # Symlinks are not shown - no idea how to distinguish them |
25 | 25 | # Read-only files are not shown as such - it's rarely useful |
| 26 | |
26 | 27 | ugid="`id -nu` `id -ng`" |
| 28 | |
27 | 29 | date_re='^\(....\)-\(..\)-\(..\) \(..:..:..\)' |
28 | 30 | date_mc='\2-\3-\1 \4' |
29 | 31 | size_re='............' |
| 32 | |
30 | 33 | # archive entries can have no datetime info, 7z will use archive file datetime |
31 | 34 | date_archive=`stat -c %y "$1" 2>/dev/null | sed -n "s/${date_re}.*/${date_mc}/p" 2>/dev/null` |
32 | 35 | [ "${date_archive}"x = x ] && date_archive=`ls -lan "$1" 2>/dev/null | awk '{print $6,"",$7,"",$8}' 2>/dev/null` |
33 | 36 | [ "${date_archive}"x = x ] && date_archive="01-01-1970 00:00:00" |
34 | | $P7ZIP l "$1" | sed -n "s/$date_re D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_mc \5/p;\ |
35 | | s/$date_re \..... \($size_re\) $size_re\(.*\)/-rw-r--r-- 1 $ugid \5 $date_mc \6/p;\ |
36 | | s/^\s*D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_archive \1/p;\ |
37 | | s/^\s*\..... \($size_re\) $size_re\(.*\)/-rw-r--r-- 1 $ugid \1 $date_archive \2/p" |
| 37 | |
| 38 | $P7ZIP l "$1" | sed -n " |
| 39 | |
| 40 | # Handle directories. |
| 41 | s/$date_re D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_mc \5/p |
| 42 | s/^\s*D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_archive \1/p |
| 43 | |
| 44 | # Handle normal files. |
| 45 | s/$date_re \..... \($size_re\) $size_re\(.*\)/-rw-r--r-- 1 $ugid \5 $date_mc \6/p |
| 46 | s/^\s*\..... \($size_re\) $size_re\(.*\)/-rw-r--r-- 1 $ugid \1 $date_archive \2/p |
| 47 | " |
38 | 48 | } |
39 | 49 | |
40 | 50 | mcu7zip_copyout () |