]>
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>
17 #include "compress_gz.h"
18 #include "compress_bz.h"
19 #include "compress_xz.h"
22 /* In case you are wondering why the file magic is not in one place:
23 * It could be. But there is little (any?) benefit.
24 * What is important is that the file magic required for any _task_ is centralised.
25 * One such task is identifying compresss
27 * to federate into each class one might add a magic parameter to the constructor, which
28 * the class could test itself.
31 #define longest_magic 14 /* lzma_alone */
34 compress::decompress (io_stream
* original
)
38 char magic
[longest_magic
];
39 if (original
->peek (magic
, longest_magic
) > 0)
41 if (memcmp (magic
, "\037\213", 2) == 0)
44 compress_gz
*rv
= new compress_gz (original
);
48 rv
->release_original();
52 else if (memcmp (magic
, "BZh", 3) == 0)
54 compress_bz
*rv
= new compress_bz (original
);
58 rv
->release_original();
62 else if (compress_xz::is_xz_or_lzma (magic
, 14))
64 compress_xz
*rv
= new compress_xz (original
);
68 rv
->release_original();
76 compress::~compress () {}
This page took 0.041855 seconds and 6 git commands to generate.