title: Using zlib to compress a directory
body: <p>I have a C++ application that requires using a standard compression format for a directory.
  I thought about using zip format.
  And therefore, zlib was obvious.</p>
  
  <p><strong>My problem is building the dictionary, i.e. compressing a directory containing some files with zlib to a standard zip file.</strong></p>
  
  <p>I have read that zlib does it but I don't understand how. I've checked minzip code.  It seems to use gzip. I could build my own format but I want to be able to open these files using 7z for debugging (just in case).</p>
  
  <p><strong>What should I use in zlib to compress a directory?</strong></p>
  
  <p>[edit]
  <strong>In minzip</strong>
  I used minzip to compress 1 file into its gz version -> not zip but fine to me. (I will have that on various compilers in the world -- having a standard format is easier in case there is an issue on the client's platform)</p>
  
  <p>Also, there is this code in <code>main</code>. It loops on a list of files and writes it to an output.
  But where is the information on the file location in the archive?</p>
  
  <pre><code>    do {
          if (uncompr) {
              if (copyout) {
                  file = gzopen(*argv, "rb");
                  if (file == NULL)
                      fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
                  else
                      gz_uncompress(file, stdout);
              } else {
                  file_uncompress(*argv);
              }
          } else {
              if (copyout) {
                  FILE * in = fopen(*argv, "rb");
  
                  if (in == NULL) {
                      perror(*argv);
                  } else {
                      file = gzdopen(fileno(stdout), outmode);
                      if (file == NULL) error("can't gzdopen stdout");
  
                      gz_compress(in, file);
                  }
  
              } else {
                  file_compress(*argv, outmode);
              }
          }
      } while (argv++, --argc);
  </code></pre>
  
  <p>Sorry if this is obvious.</p>