]>
cygwin.com Git - cygwin-apps/setup.git/blob - compress.cc
2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 /* Archive IO operations
20 static const char *cvsid
=
28 #include "io_stream.h"
30 #include "zlib/zlib.h"
31 #include "compress_gz.h"
32 #include "compress_bz.h"
34 /* In case you are wondering why the file magic is not in one place:
35 * It could be. But there is little (any?) benefit.
36 * What is important is that the file magic required for any _task_ is centralised.
37 * One such task is identifying compresss
39 * to federate into each class one might add a magic parameter to the constructor, which
40 * the class could test itself.
43 #define longest_magic 3
46 compress::decompress (io_stream
* original
)
50 char magic
[longest_magic
];
51 if (original
->peek (magic
, longest_magic
) > 0)
53 if (memcmp (magic
, "\037\213", 2) == 0)
56 compress_gz
*rv
= new compress_gz (original
);
61 else if (memcmp (magic
, "BZh", 3) == 0)
63 compress_bz
*rv
= new compress_bz (original
);
73 compress::read (void *buffer
, size_t len
)
75 log (LOG_TIMESTAMP
, "compress::read called");
80 compress::write (void *buffer
, size_t len
)
82 log (LOG_TIMESTAMP
, "compress::write called");
87 compress::peek (void *buffer
, size_t len
)
89 log (LOG_TIMESTAMP
, "compress::peek called");
96 log (LOG_TIMESTAMP
, "bz::tell called");
103 log (LOG_TIMESTAMP
, "compress::error called");
108 compress::next_file_name ()
110 log (LOG_TIMESTAMP
, "compress::next_file_name called");
114 compress::~compress ()
116 log (LOG_BABBLE
, "compress::~compress called");
This page took 0.04366 seconds and 6 git commands to generate.