summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/zziplib-src/bins/zzdir.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-02-22 06:41:00 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-02-22 06:41:00 +0000
commit553ae4df24322a4fb019c63b81e98093f2b1a6a2 (patch)
tree4d12a0e51045a061e650c7b5484822703c8d2904 /Build/source/libs/zziplib/zziplib-src/bins/zzdir.c
parent7e3d9b4d0fea3356761f420fccbce2bb4aa30442 (diff)
libs/zziplib: New convention
git-svn-id: svn://tug.org/texlive/trunk@39816 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-src/bins/zzdir.c')
-rw-r--r--Build/source/libs/zziplib/zziplib-src/bins/zzdir.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/Build/source/libs/zziplib/zziplib-src/bins/zzdir.c b/Build/source/libs/zziplib/zziplib-src/bins/zzdir.c
new file mode 100644
index 00000000000..5345f0852da
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-src/bins/zzdir.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2000,2001,2002 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ */
+
+#include <zzip/zzip.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static const char usage[] =
+{
+ "zzdir <dir>.. \n"
+ " - prints a content table to stdout, but the dir can also be a zip-arch."
+ "\n"
+ " To show the contents of a zip-archive named 'test.zip', you may write \n"
+ " zzdir test \n"
+};
+
+int
+main (int argc, char ** argv)
+{
+ int argn;
+ int exitcode = 0;
+
+ if (argc <= 1 || ! strcmp (argv[1], "--help"))
+ {
+ printf (usage);
+ return 0;
+ }
+ if (! strcmp (argv[1], "--version"))
+ {
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return 0;
+ }
+
+ for (argn=1; argn < argc; argn++)
+ {
+ ZZIP_DIR * dir;
+ ZZIP_DIRENT * d;
+
+ dir = zzip_opendir(argv[argn]);
+ if (! dir)
+ {
+ fprintf (stderr, "did not open %s: ", argv[argn]);
+ perror(argv[argn]);
+ exitcode++;
+ continue;
+ }
+
+ if (argc > 2) printf ("%s: \n", argv[argn]);
+
+ /* read each dir entry and show one line of info per file */
+ while ((d = zzip_readdir (dir)))
+ {
+ /* orignalsize / compression-type / compression-ratio / filename */
+ if (d->st_size > 999999)
+ {
+ printf ("%5dK %-9s %2d%% %s \n",
+ d->st_size>>10,
+ zzip_compr_str(d->d_compr),
+ 100 - (d->d_csize|1)/((d->st_size/100)|1),
+ d->d_name);
+ }else{
+ printf ("%6d %-9s %2d%% %s \n",
+ d->st_size,
+ zzip_compr_str(d->d_compr),
+ 100 - (d->d_csize|1)*100/(d->st_size|1),
+ d->d_name);
+ }
+ }
+
+ zzip_closedir(dir);
+ }
+
+ return exitcode;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */