3 * Guido Draheim <guidod@gmx.de>
5 * Copyright (c) 2000,2001,2002,2003 Guido Draheim
7 * use under the restrictions of the
8 * Lesser GNU General Public License
9 * or alternatively the restrictions
10 * of the Mozilla Public License 1.1
13 #include <zzip/lib.h> /* exported... */
14 #include <zzip/file.h>
15 #include <zzip/format.h>
17 #ifdef ZZIP_HAVE_SYS_STAT_H
25 * just returns dir->errcode of the ZZIP_DIR handle
26 * see: => zzip_dir_open, => zzip_diropen, => zzip_readdir, => zzip_dir_read
29 zzip_error(ZZIP_DIR * dir)
35 * This function just does dir->errcode = errcode
38 zzip_seterror(ZZIP_DIR * dir, int errcode)
39 { dir->errcode = errcode; }
42 * This function will just return fp->dir
44 * If a ZZIP_FILE is contained within a zip-file that one will be a valid
45 * pointer, otherwise a NULL is returned and the ZZIP_FILE wraps a real file.
48 zzip_dirhandle(ZZIP_FILE * fp)
54 * This function will just return dir->fd
56 * If a ZZIP_DIR does point to a zipfile then the file-descriptor of that
57 * zipfile is returned, otherwise a NULL is returned and the ZZIP_DIR wraps
58 * a real directory DIR (if you have dirent on your system).
61 zzip_dirfd(ZZIP_DIR* dir)
67 * return static const string of the known compression methods,
68 * otherwise just "zipped" is returned
71 zzip_compr_str(int compr)
75 case ZZIP_IS_STORED: return "stored";
76 case ZZIP_IS_SHRUNK: return "shrunk";
77 case ZZIP_IS_REDUCEDx1:
78 case ZZIP_IS_REDUCEDx2:
79 case ZZIP_IS_REDUCEDx3:
80 case ZZIP_IS_REDUCEDx4: return "reduced";
81 case ZZIP_IS_IMPLODED: return "imploded";
82 case ZZIP_IS_TOKENIZED: return "tokenized";
83 case ZZIP_IS_DEFLATED: return "deflated";
84 case ZZIP_IS_DEFLATED_BETTER: return "deflatedX";
85 case ZZIP_IS_IMPLODED_BETTER: return "implodedX";
87 if (0 < compr && compr < 256) return "zipped";
91 if (S_ISDIR(compr)) return "directory";
94 if (S_ISCHR(compr)) return "is/chr";
97 if (S_ISBLK(compr)) return "is/blk";
100 if (S_ISFIFO(compr)) return "is/fifo";
103 if (S_ISSOCK(compr)) return "is/sock";
106 if (S_ISLNK(compr)) return "is/lnk";
113 /** => zzip_file_real
114 * This function checks if the ZZIP_DIR-handle is wrapping
115 * a real directory or a zip-archive.
116 * Returns 1 for a stat'able directory, and 0 for a handle to zip-archive.
119 zzip_dir_real(ZZIP_DIR* dir)
121 return dir->realdir != 0;
125 * This function checks if the ZZIP_FILE-handle is wrapping
126 * a real file or a zip-contained file.
127 * Returns 1 for a stat'able file, and 0 for a file inside a zip-archive.
130 zzip_file_real(ZZIP_FILE* fp)
132 return fp->dir == 0; /* ie. not dependent on a zip-arch-dir */
135 /** => zzip_file_real
136 * This function returns the posix DIR* handle (if one exists).
137 * Check before with => zzip_dir_real if the
138 * the ZZIP_DIR points to a real directory.
141 zzip_realdir(ZZIP_DIR* dir)
146 /** => zzip_file_real
147 * This function returns the posix file descriptor (if one exists).
148 * Check before with => zzip_file_real if the
149 * the ZZIP_FILE points to a real file.
152 zzip_realfd(ZZIP_FILE* fp)
159 * c-file-style: "stroustrup"