-
Notifications
You must be signed in to change notification settings - Fork 0
/
fv
executable file
·789 lines (698 loc) · 22.6 KB
/
fv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
#!/bin/sh
# fv - archive and package directory lister
#
# Copyright (c) 2003-2024 Dan Fandrich <[email protected]>
# Licensed under the MIT license (see LICENSE).
#
# Format of archive entries in this file:
#
# * The requires: comment lines below the archive name refer to the
# software package(s) required to view the content list of the archive
# (RedHat package names are listed in most cases). This information is not
# currently used by the program but is merely a note to the curious user
# who wants to know how to look inside a new archive type.
#
# * An archive_label line must be found within the code handling each
# archive type. Any special shell characters must be enclosed in single
# quotes. These lines are listed (along with the Also lines) using the
# -v -l option.
#
# * A comment line beginning See gives a URL with more information about
# the archive format. This information is not currently used by
# the program but is merely a note to the curious user.
#
# * A comment line beginning Also gives an alternative archive name for the
# following archive type similar to the format of archive_label, except
# that the comment ends with the file extension and special shell characters
# must not be quoted. These lines are listed along with the archive_label
# lines using the -v -l option.
#
# * Each case entry line matching a file extension must have a tab character
# in the first position. These extensions are listed using the -l option.
usage () {
echo 'fv ver. 8-dev'
echo 'Displays directory listings for many archive types.'
echo ''
echo 'Usage: fv [-v] [-?] [-h] [-l] [-t type] archive1 [ archive2 ... ]'
echo ' -v show verbose output (more than once for more verbosity)'
echo ' -h, -? show this help'
echo ' -l list supported file extensions (or file types with -v)'
echo ' -t treat the archives as having the specified file extension'
exit 3
}
if [ X"$1" = X"-v" ] ; then
FV_VERBOSE=1
shift
if [ X"$1" = X"-v" ] ; then
FV_VERBOSE=2
shift
fi
fi
if [ $# -eq 0 -o X"$1" = X"-?" -o X"$1" = X"-h" ] ; then
usage
fi
if [ X"$1" = X"-l" ] ; then
# requires: textutils, sed
if [ X"$FV_VERBOSE" != X ] ; then
# Scan this script looking for archive label lines and Also comments
sed -n -e "s/'//g" -e 's/^[^#]\+archive[_]label //p' \
-e 's/^[ ]*# Also \(.*\) [\.a-z0-9A-Z,_]*$/\1/p' "$0" | sort -f | uniq
else
echo 'Supported file extensions:'
# Scan this script looking for wildcard case statement entries
sed -n -e 's/^[ ][ ]*\(\*[^#)]*\)[)\\].*$/\1/p' "$0" | sed -e 's/ *| */\
/g' | sed -e 's/\*//g' -e '/^\**$/d' | sort -f | uniq | fmt
fi
exit
fi
staticfiletype=""
if [ X"$1" = X"-t" ] ; then
staticfiletype="$2"
# Make sure file type starts with . for comparision purposes
case "$staticfiletype" in
.*) ;;
*) staticfiletype=".$staticfiletype"
;;
esac
shift
shift
fi
if [ $# -eq 0 ] ; then
usage
fi
archive_label () {
# Display the archive name in verbose mode
if [ X"$FV_VERBOSE" != X ] ; then
echo "$*"
if [ X"$FV_VERBOSE" = X2 ] ; then
# echo the actual command used to display the archive
set -x
fi
fi
}
# Make a filename starting with a dash - safe to provide a program that
# would interpret it as an option.
safefn () {
case "$1" in
-*) echo "./$1" ;;
*) echo "$1" ;;
esac
}
# Check if 'tar' needs the --wildcards option for globbing
# Set the TAR_WILDCARDS environment variable with the appropriate option
TAR_WILDCARDS=
checked_tar_wildcards=
check_tar_wildcards () {
if [ -n "$checked_tar_wildcards" ]; then
# We've already done the check
return
fi
if tar --help 2>&1 | grep '[-]-wildcards' >/dev/null; then
TAR_WILDCARDS=--wildcards
fi
checked_tar_wildcards=yes
}
for f in "$@" ; do
# "safe" filename guaranteed not to start with a dash
sf="`safefn "$f"`"
if [ X"$staticfiletype" = X"" ] ; then
filetype=`basename "$sf"`
else
filetype="$staticfiletype"
fi
echo "$f":
case "$filetype" in
# See https://p7zip.sourceforge.net/
# requires: p7zip
*.7z) archive_label 7zip archive
7za l -- "$f"
;;
# requires: binutils
*.a | *.sa) archive_label ar archive
ar tv -- "$f"
;;
# requires: linunace
*.ace) archive_label ACE archive
unace v "$sf"
;;
# See http://www.kipple.pe.kr/win/unalz/ (defunct as of 2021)
# requires: unalz
*.alz) archive_label ALZ archive
unalz -l "$sf"
;;
# See https://github.com/AppImage/AppImageKit/
# requires: appimagetool
*.AppImage) archive_label AppImage package
appimagetool --list --verbose -- "$f"
;;
# requires: arc
*.arc) archive_label SEA ARC archive
arc v "$sf"
;;
# requires: nspark
# Extension is really .arc, but that conflicts with SEA ARC
*.spark) archive_label 'Archimedes Spark archive (RiscOS)'
nspark -l -v "$sf"
;;
# requires: unarj || arj
*.arj) archive_label ARJ archive
unarj l "$f" || arj l -- "$f"
;;
# See https://crates.io/crates/blend_info
# requires: blend_info
*.blend) archive_label Blender file
blend_info -- "$f"
;;
# See http://www.star.le.ac.uk/~tjg/bun/ (defunct as of 2021)
# requires: bun
# (Untested)
*.bun) archive_label BUN archive
bun tv "$sf"
;;
# requires: cabextract
# Also Microsoft Installer .msi
# Also Microsoft OneNote package .onepkg
*.cab | *.msi | *.onepkg) archive_label Microsoft Cabinet archive
cabextract -l -- "$f"
;;
# See http://wiki.conary.com/wiki/Conary (defunct as of 2021)
# requires: conary
*.ccs) archive_label Conary Change Set
conary showcs --info --all --all-troves --trove-headers --info --lsl --no-recurse "$sf"
;;
# snd+gfx--see sasteroids
*.cf) archive_label Compound File Compiler archive
cvf "$sf"
;;
# requires: chmlib
*.chm) archive_label Microsoft Compressed HTML
enum_chmLib "$sf"
;;
# requires: cpio, gzip
*.cpio.gz | *.cpio.Z | *.cpio.z | *.cgz)
archive_label compressed cpio archive
gzip -dc -- "$f" | cpio -itv
;;
# requires: cpio, bzip2
*.cpio.bz2) archive_label bzip2-compressed cpio archive
bzip2 -dc -- "$f" | cpio -itv
;;
# requires: cpio
*.cpio) archive_label cpio archive
cpio -itv < "$f"
;;
# requires: rpmtools
# see https://metacpan.org/dist/MDK-Common
hdlist.cz | hdlist.cz2) archive_label URPM hdlist file
packdrake --list "$sf"
;;
# See http://dar.linux.free.fr/
# requires: dar >= 2.7.0
*.dar) archive_label Disk Archiver archive
dar -Q -ay -alist-ea -l "$f"
;;
# requires: binutils, gzip, tar, xz, zstd
# On a Debian system, this should use 'dpkg -c "$f"' instead
# Also OpenMoko package .opk
*.deb | *.opk) archive_label Debian distribution archive
case "$(ar t -- "$f" data.tar.zst data.tar.xz data.tar.gz 2>/dev/null)" in
*zst) ar p -- "$f" data.tar.zst | zstd -dc | tar tvf - ;;
*xz) ar p -- "$f" data.tar.xz | xz -qdc | tar tvf - ;;
*gz) ar p -- "$f" data.tar.gz | gzip -qdc | tar tvf - ;;
*) echo Error: unknown deb compression 1>&2 ;;
esac
;;
# See https://github.com/sgan81/apfs-fuse/
# requires dmg2img, kpartx, apfs_fuse
# This requires root to mount and unmount partitions
*.dmg) archive_label Apple disk image
FVTMPDIR="`mktemp -d`"
dmg2img "$sf" "$FVTMPDIR/image.img"
DMGDEVICE="`sudo kpartx -asrv "$FVTMPDIR/image.img" | awk '/^add map/ {print "/dev/mapper/" $3}'`"
if [ -z "$FVTMPDIR" -o -z "$DMGDEVICE" ] ; then
echo "Error: cannot manipulate DMG file; are dmg2img and kpartx installed?"
# Indicate that an error has occurred
false
else
mkdir "$FVTMPDIR/mnt"
# The kernel itself can mount an HFS dmg, so use apfs-fuse only if that fails
sudo mount -r "$DMGDEVICE" "$FVTMPDIR/mnt" 2>/dev/null || sudo apfs-fuse -o allow_other "$DMGDEVICE" "$FVTMPDIR/mnt"
(cd "$FVTMPDIR/mnt" && find . -exec ls -ld {} +)
# clean up
sudo umount "$FVTMPDIR/mnt"
sudo kpartx -d "$FVTMPDIR/image.img"
rm -f "$FVTMPDIR/image.img"
rmdir -p "$FVTMPDIR"/* 2>/dev/null
fi
;;
# See http://www.handhelds.org/ (defunct as of 2021)
# requires: binutils, file, grep, gzip, tar
*.ipk) archive_label Itsy package
# Detect the old or new style ipk format
if file -- "$f" | egrep -iq 'Debian|ar archive' ; then
ar -p "$sf" data.tar.gz | gzip -dc | tar tvf -
else
# Internal file name may or may not be prefixed with ./
# which is what the * catches.
check_tar_wildcards
gzip -dc -- "$f" | tar xOf - $TAR_WILDCARDS '*data.tar.gz' | gzip -dc | tar tvf -
fi
;;
# requires: binutils, gzip, tar
# Also Ruby package .gem
*.gem) archive_label Ruby package
tar xOf - data.tar.gz < "$f" | gzip -dc | tar tvf -
;;
# I've forgotten what this is
*.ha) archive_label ha archive
ha l "$sf"
;;
# requires: sed
*.hp) archive_label HP48 distribution archive as posted to comp.sources.hp48
sed -n -e 's/^\(BEGIN_.*\) /\1 /p' < "$f"
;;
# requires: macutils
*.hqx) archive_label Macintosh BinHex encoding
hexbin -il "$sf"
;;
# requires: cdrecord
*.iso) archive_label ISO9660 filesystem image file
isoinfo -l -R -i "$f"
;;
# requires: mtd-utils
# This just dumps file names without directory structure, but it's
# better than nothing. jffs2dump provides enough information to show
# file size as well as which files have extended attributes, but that
# would mean more post-processing to track inodes.
*.jffs2) archive_label JFFS2 filesystem image file
jffs2dump -c "$sf" | sed -n '/^ *Dirent/s/^.*, name //p'
;;
# See http://rus.members.beeb.net/lbrate.html (defunct as of 2021)
# requires: lbrate
*.lbr) archive_label CP/M LBR archive
lbrate -vl "$sf"
;;
# requires: lha || lhasa
*.lha | *.lzh) archive_label LHARC archive
lha -v "$sf" 2>/dev/null || lhasa v - < "$f"
;;
# (Is .mac the most common suffix for MacBinary files?)
# requires: macutils
*.mac) archive_label Macintosh MacBinary encoding
macsave -il < "$f"
;;
# Found this one on SCO UNIX
# (Don't know what kind of suffix this one uses)
# (Untested)
#*.mar) archive_label Message catalogue archive
# mar tv "$f"
# ;;
# See http://www.emantic.co.uk/mark/ (defunct as of 2021)
# requires: mar
# (Untested)
*.mar) archive_label Meta Archive
mar -t "$sf"
;;
# See http://www.dakotacom.net/~donut/programs/par2ls.html (defunct as of 2021)
# requires: par2ls
# (Untested)
*.par2) archive_label Parity Archive ver. 2
par2ls "$sf"
;;
# requires: pilot-link
*.pdb | *.prc) filetype_label Palm Pilot file
pilot-file -Hasl -- "$f"
;;
# requires: poppler
*.pdf | *.ai) archive_label Portable Document Format document
pdfimages -list -- "$f"
pdfdetach -list -- "$f"
;;
# See http://www.pcbsd.org/ (defunct as of 2021)
# requires: tar, sed, bzip2
*.pbi) archive_label PC-BSD package
sed '1,/^__PBI_ARCHIVE__$/d' < "$f" | bzcat | tar xOf - Package.tar | tar tvf -
;;
# (Don't know what kind of suffix this one uses)
# (Untested)
*.pkg) archive_label 'SysV package (SCO UNIX, IRIX)'
pkginfo -d "`dirname -- "$f"`" -l "`basename "$sf"`"
;;
# See http://en.pardus-wiki.org/Package-manager (defunct as of 2021)
# requires: lzma, tar, unzip
*.pisi) archive_label Pardus package
unzip -pq "$sf" install.tar.lzma | lzma -dc | tar -tvf -
;;
# See https://mattmahoney.net/dc/
# See https://sourceforge.net/projects/kgbarchiver/
# Also KGB archive .kgb
*.pq6 | *.kgb) archive_label PAQ6 compressed archive
sed '//,$d' < "$f"
;;
# See https://www.puppylinux.com/
# requires: gzip, tar, unzip
*.pup)
archive_label Puppy Linux package
if unzip -l "$sf" dotpop.tar.gz >/dev/null; then
unzip -p "$sf" dotpup.tar.gz | gzip -dc | tar tvf -
else
unzip -lv "$sf"
fi
;;
# requires: unrar
# Also SNES sound archive .rsn
*.rar | *.rsn) archive_label RAR compressed archive
unrar v -idc -- "$f"
;;
# See http://www.rpm.org/
# requires: rpm
*.rpm | *.spm) archive_label Red Hat RPM package
rpm -qlvp -- "$f"
;;
# (Obsolete format; from Red Hat Linux--NOT RHEL--distributions < 4.0)
# See https://www.redhat.com/
# requires: tar, cpio, gzip
*.rpp) archive_label Red Hat RPP package
tar xOf - cpio-archive.gz < "$f" | gzip -dc | cpio -itv
;;
# See https://rzip.samba.org/
# requires: python >= 3
*.rz) archive_label rzip archive
python3 - "$f" <<EOF
import struct, sys, os
fn=sys.argv[1]
with open(fn, 'rb') as f:
magic,ver1,ver2 = struct.unpack('4sBB', f.read(6))
if magic!=b'RZIP': print('Not an rzip archive', file=sys.stderr); sys.exit(1);
length = struct.unpack('!II', f.read(8))
basefn=os.path.basename(fn).rsplit('.')[0]
print('rz ver length filename')
print('%2d.%02d %10d %s' % (ver1,ver2, length[1] * 0x100000000 + length[0], basefn))
EOF
;;
# See https://sourceforge.net/projects/sistk/
# requires: DumpSIS
*.sis) archive_label SymbianOS SIS installable package
DumpSIS.pl -t -- "$f"
;;
# requires: macutils
*.sit) archive_label Macintosh StuffIt archive
macunpack -il "$sf"
;;
# There are many kinds of shar archives with greatly differing
# formats. This code attempts to find a manifest listing in the
# comments at the top of the file in several different formats.
# requires: sed
*.shar | *.sh) archive_label shell archive
# display warning
echo 'NOTE: shar contents listing is not completely reliable'
# GNU shar 4.1
sed -n -e '1,/^# This shar contains/d' -e '/^#$/,$d' -e 's/^# //p' < "$f"
# shar type A
sed -n -e '1,/with \/bin\/sh/d' -e '/^#$/,$d' -e 's/^#[ ]/ /p' < "$f"
# shar type B
sed -n -e '/^#/!d' -e '/^# end of/d' -e 's/^#[ ]//' -e '/^Contents/,$p' < "$f"
;;
# See https://nulib.com/
# requires: nulib
*.shk | *.sh2 | *.sdk | *.bxy) archive_label Apple II archive
nulib tv "$sf"
;;
# *.cbmarc extension is .arc, but that conflicts with SEA ARC
# See https://github.com/dfandrich/fvcbm/
# requires: fvcbm
# *.lzh and *.lha can be handled by fvcbm, but are taken care of
# by lha above
# *.lbr types conflict and are taken care of earlier
*.sda | *.sfx | *.d64 | *.d71 | *.d80 | *.d81 | *.d82 | *.x64 | \
*.t64 | *.tap | *.lnx | *.n64 | *.lbr | *.[psrud]0[0-9] | \
*.cbmarc) archive_label Commodore 64 archive
fvcbm "$sf"
;;
# See https://github.com/plougher/squashfs-tools/
# Also Snap package .snap
# requires: squashfs
*.sqsh | *.squashfs | *.sqfs | *.snap) archive_label Squashfs filesystem image
unsquashfs -ll "$sf"
;;
# gzip-compressed tar archive .tar.gz
# Also Netscape package .nif
# Also eCos package .epk
# Also QNX package .qpk
# Also QNX package archive .qpr
# Also Frugalware package .fpm
# Also HP-UX package .depot.gz
# Also Rubix package .rub
# Also KWord Document .kwd
# Also KSpread Spreadsheet .ksp
# Also KPresenter Document .kpr
# Also KChart Chart .chrt
# Also KFormula Document .kfo
# Also Kivio Document .flw
# Also Kontour Illustration .kil
# requires: tar, gzip
*.nif | *.epk | *.qpk | *.qpr | *.depot.gz | *.fpm | *.rub | \
*.kpr | *.chrt | *.kfo | *.flw | *.kil | *.ksp | *.kwd | \
*.tar.z | *.tar.Z | *.tar.gz | *.tgz | *.taz | *.taZ)
archive_label gzip-compressed tar archive
gzip -dc -- "$f" | tar tvf -
;;
# lzip-compressed tar archive .tar.lz
# requires: tar, lzip
*.tar.lz)
archive_label lzip-compressed tar archive
lzip -dc -- "$f" | tar tvf -
;;
# lzo-compressed tar archive .tar.lzop
# requires: tar, lzop
*.tar.lzo)
archive_label lzop-compressed tar archive
lzop -dc -- "$f" | tar tvf -
;;
# zstd-compressed tar archive .tar.zst
# requires: tar, zstd
*.tar.zst | *.tzst)
archive_label zstd-compressed tar archive
zstd -dc -- "$f" | tar tvf -
;;
# .pet gets its own entry to give gzip the -q option; otherwise it
# complains about the CRC tacked on to the end
# requires: tar, gzip
*.pet)
archive_label Puppy Linux Extra Treats package
gzip -qdc -- "$f" | tar tvf -
;;
# bzip2-compressed tar archive .tar.bz2, .tbz, .tbz2
# Also Stampede Linux package .slp
# requires: tar, bzip2
*.slp | \
*.tar.bz2 | *.tbz | *.tbz2 | *.tz2) archive_label bzip2-compressed tar archive
bzip2 -dc -- "$f" | tar tvf -
;;
# Also Midnight BSD ports package .mport
# requires: tar, xz
*.tar.xz | *.txz | *.mport)
archive_label xz-compressed tar archive
xz -dc -- "$f" | tar tvf -
;;
# tar archive .tar
# Also tardist IRIX package .tardist
# Also Lua package .lpkg
# Also stopmotion movie .sto
# Also HP-UX package .depot
# requires: tar
*.tar | *.tardist | *.lpkg | *.sto | *.depot) archive_label tar archive
tar tvf - < "$f"
;;
# Also Tukaani Linux package .tlz
# requires: lzma, tar
*.tlz | *.tar.lzma) archive_label LZMA compressed tar archive
lzma -dc -- "$f" | tar tvf -
;;
# See https://www.denx.de/wiki/U-Boot/
# requires: coreutils, cpio, gzip
*.uRamdisk) archive_label U-boot ramdisk image
tail -c +65 < "$f" | gzip -dc | cpio -itv
;;
# See https://jmtd.net/doom/
# requires: lswad
*.wad) archive_label Doom WAD archive
lswad "$sf"
;;
# See https://tnef.sourceforge.net/
# requires: tnef
# (Untested)
*winmail.dat) archive_label Microsoft TNEF e-mail attachment
tnef -t -- "$f"
;;
# requires: sed
*.uu | *.uue | *.uua) archive_label uuencoded file
sed -n 's/^begin //p' < "$f"
;;
# See http://xar.googlecode.com/ (defunct as of 2021)
# requires: xar
*.xar) archive_label XAR archive
xar -t -f "$sf"
;;
# zip archive .zip
# Also Android package .apk
# Also Apkmirror Android package .apkm
# Also Java jar file .jar
# Also Mozilla Java Cross Platform Installer .xpi
# Also Perl package .par
# Also Winamp compressed skin file .wsz,.wal
# Also Google Earth .kmz
# Also iPod Game .ipg
# Also OpenOffice Impress Presentation .sxi
# Also OpenOffice Drawing .sxd
# Also OpenOffice Math .sxm
# Also OpenOffice Writer Document .sxw
# Also OpenDocument Document .odt
# Also OpenDocument Chart .odc
# Also OpenDocument Database .odb
# Also OpenDocument Drawing .odg
# Also OpenDocument Spreadsheet .ods
# Also OpenDocument Presentation .odp
# Also OpenDocument Formula .odf
# Also OpenDocument Drawing Template .otg
# Also OpenDocument Presentation Template .otp
# Also OpenDocument Spreadsheet Template .ots
# Also OpenDocument Presentation Template .otp
# Also OpenDocument Extension .oxt
# Also Quake3 packed file .pk3
# Also Nokia mobile phone theme .nth
# Also Microsoft Office Open XML document .docx
# Also Microsoft Office Open XML document with Macros .docm
# Also Microsoft Office Open XML presentation .pptx
# Also Microsoft Office Open XML spreadsheet .xlsx
# Also EPub Document .epub
# Also Java Web Start .war
# Also XML Paper Specification .xps
# Also Syllable resource package .resource
# Also Syllable application package .application
# Also (unknown 3D package) .f3d
# Also Python package .egg
# Also Python wheel package .whl
# Also Krita image .kra
# Also 3-D Manufacturing format .3mf
# Also Scratch Project .sb2
# Also Scratch Project .sb3
# Also OpenRaster image .ora
# Also Tellico database .tc
# Also Wondershare Filmora Project .wfp
# Also Web Archive Collection Zipped .wacz
# Also MuseScore music score .mscz
# SkyOS .pkg file are in .zip format, but the extension conflicts
# requires: unzip
*.zip | *.jar | *.xpi | *.par | *.wsz | *.wal | *.kmz | \
*.sxi | *.sxd | *.sxw | *.sxm | *.pk3 | *.ipg | *.nth | *.odt | \
*.ods | *.odp | *.odg | *.odf | \
*.otp | *.otg | *.ots | *.odb | *.odc | *.oxt | \
*.docx | *.epub | *.apk | *.apkm | *.war | *.xps | *.resource | \
*.application | *.docm | *.f3d | *.egg | *.kra | *.whl | *.3mf | \
*.sb2 | *.sb3 | *.ora | *.tc | *.wfp | *.wacz | *.xlsx | *.pptx | \
*.mscz)
archive_label ZIP archive
unzip -v "$sf"
;;
# requires: unzoo || zoo
*.zoo) archive_label ZOO archive
unzoo -l "$sf" || zoo -list "$sf"
;;
# See https://mattmahoney.net/dc/zpaq.html
# requires: zpaq
*.zpaq) archive_label ZPAQ compressed archive
zpaq l "$sf"
;;
# See https://archives.damiendebin.net/zzip/
# requires: zzip
# (Untested)
*.zz) archive_label ZZIP archive
zzip l "$sf"
;;
# General extensions that are used more specifically above
# See https://liballeg.org/
# requires: allegro4
*.dat) archive_label Allegro4 not packed datafile
# There is also a packed Allegro4 datafile type with the same
# extension, but there seems to be no metadata within the file to
# display without uncompressing the file.
dat -l -v "$sf"
;;
# Compressed files must come after compressed archives
# requires: fileutils, textutils, sh-utils, awk, util-linux
*.bz2) archive_label bzip2-compressed file
if [ -e "$f" ] ; then
FILEINFO=`env LC_ALL=C ls -l -- "$f"`
#FILESIZE=`echo "$FILEINFO" | cut -c 30-42`
FILESIZE=`echo "$FILEINFO" | awk '{print $5}'`
FILENAME=`basename "$sf" .bz2`
#FILECRC=`od -A n -j 10 -N 4 -t x1 < "$f" | sed "s/ //g"`
FILECRC=`hexdump -e '4/1 "%02x" "\n"' -n 4 -s 10 < "$f"`
#FILECOMPRESS=`od -A n -j 3 -N 1 -t c "$f" | sed "s/ //g"`
FILECOMPRESS=`hexdump -e '"%_c" "\n"' -n 1 -s 3 < "$f"`
echo "method crc compressed uncompressed_name"
printf "bzip2-%s %8s %13s %s" "$FILECOMPRESS" "$FILECRC" "$FILESIZE" "$FILENAME"
else
echo "$f: No such file or directory"
fi
;;
# requires: gzip
*.gz | *.Z | *.z) archive_label gzip-compressed file
gzip -vl -- "$f"
;;
# requires: lzip
*.lz) archive_label LZIP compressed file
lzip -lv -- "$f"
;;
# See https://www.lzop.org/
# requires: lzop
*.lzo) archive_label LZOP compressed file
lzop -vl -- "$f"
;;
# See https://www.7-zip.org/sdk.html
# requires: lzma || python >= 3
*.lzma) archive_label LZMA compressed file
if which lzmainfo >/dev/null 2>&1 ; then
lzmainfo -- "$f"
else
python3 - "$f" <<EOF
import struct, sys, os, math
fn=sys.argv[1]
with open(fn, 'rb') as f:
prop=f.read(1) # properties
dict,length = struct.unpack('<Iq', f.read(12))
basefn=os.path.basename(fn).rsplit('.')[0]
print('dict length filename')
print('%2d %11d %s' % (math.log(dict)/math.log(2),length,basefn))
EOF
fi
;;
# requires: xz
*.xz) archive_label xz-compressed file
xz -vl -- "$f"
;;
# requires: zstd
*.zst) archive_label zstd-compressed file
zstd -l -- "$f"
;;
# Unknown format
# requires: file
*) echo "$filetype: Unsupported archive format." 1>&2
if [ X"$FV_VERBOSE" != X ] ; then
file -- "$f" 1>&2
fi
# Indicate that an error has occurred
false
;;
esac
if [ X"$FV_VERBOSE" = X2 ] ; then
set +x
fi
# Save the return code of the last program run so we can return that from
# the script. This won't work for some of the archive listers, but it's
# better than nothing.
rc=$?
echo ""
done
exit $rc