home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / Jikes / Source / src / zip.h < prev   
Encoding:
C/C++ Source or Header  |  2001-03-03  |  2.2 KB  |  112 lines

  1. // $Id: zip.h,v 1.9 2001/01/05 09:13:21 mdejong Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef zip_INCLUDED
  11. #define zip_INCLUDED
  12.  
  13. #include "platform.h"
  14.  
  15. //FIXME: need to remove ?
  16. //#ifdef WIN32_FILE_SYSTEM
  17. //#include <windows.h>
  18. //#endif
  19.  
  20. //#include <stddef.h>
  21. //#include <stdio.h>
  22.  
  23. #include "tuple.h"
  24. #include "unzip.h"
  25.  
  26. #ifdef    HAVE_JIKES_NAMESPACE
  27. namespace Jikes {    // Open namespace Jikes block
  28. #endif
  29.  
  30. class Control;
  31. class Zip;
  32. class DirectorySymbol;
  33. class FileSymbol;
  34. class NameSymbol;
  35.  
  36.  
  37. class ZipFile : public Unzip
  38. {
  39. public:
  40.  
  41.     ZipFile(FileSymbol *);
  42.     ~ZipFile();
  43.  
  44. private:
  45.     char *buffer;
  46.  
  47.     u1 GetU1();
  48.     u2 GetU2();
  49.     u4 GetU4();
  50.     void Skip(u4 length);
  51.  
  52. #if defined(UNIX_FILE_SYSTEM) || defined(AMIGAOS_FILE_SYSTEM)
  53.         FILE *zipfile;
  54.         static int (*uncompress_file[10]) (FILE *, char *, long);
  55.     public:
  56.         inline char *Buffer() { return buffer; }
  57. #elif defined(WIN32_FILE_SYSTEM)
  58.         char *file_buffer;
  59.         static int (*uncompress_file[10]) (char *, char *, long);
  60.     public:
  61.         inline char *Buffer() { return (buffer ? buffer : file_buffer); }
  62. #endif
  63. };
  64.  
  65.  
  66. class Zip
  67. {
  68. public:
  69.     Zip(Control &, char *);
  70.     ~Zip();
  71.  
  72.     bool IsValid() { return magic == 0x06054b50; }
  73.  
  74.     DirectorySymbol *RootDirectory() { return root_directory; }
  75.  
  76. private:
  77.     friend class ZipFile;
  78.  
  79.     Control &control;
  80.  
  81.     u4 magic;
  82.  
  83.     DirectorySymbol *root_directory;
  84.  
  85.     char *zipbuffer,
  86.          *buffer_ptr;
  87.  
  88.     u1 GetU1();
  89.     u2 GetU2();
  90.     u4 GetU4();
  91.     void Skip(u4 length);
  92.  
  93.     void ReadDirectory();
  94.  
  95.     NameSymbol *ProcessFilename(char *, int);
  96.     DirectorySymbol *ProcessSubdirectoryEntries(DirectorySymbol *, char *, int);
  97.     void ProcessDirectoryEntry();
  98.  
  99. #if defined(UNIX_FILE_SYSTEM) || defined(AMIGAOS_FILE_SYSTEM)
  100.     FILE *zipfile;
  101. #elif defined(WIN32_FILE_SYSTEM)
  102.     HANDLE zipfile, mapfile;
  103. #endif
  104. };
  105.  
  106. #ifdef    HAVE_JIKES_NAMESPACE
  107. }            // Close namespace Jikes block
  108. #endif
  109.  
  110. #endif /* zip_INCLUDED */
  111.  
  112.