Translated using Weblate (Chinese (Simplified))
[cygwin-setup.git] / compress_zstd.h
blobb9b541e8fb362795eedaf38d5b92e5d14330fdbf
1 /*
2 * Copyright (c) 2018, Cygwin
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
10 * http://www.gnu.org/
14 #ifndef SETUP_COMPRESS_ZSTD_H
15 #define SETUP_COMPRESS_ZSTD_H
17 #include "compress.h"
18 #include <zstd.h>
20 class compress_zstd:public compress
22 public:
23 compress_zstd (io_stream *); /* decompress (read) only */
24 virtual ssize_t read (void *buffer, size_t len);
25 virtual ssize_t write (const void *buffer, size_t len); /* not implemented */
26 virtual ssize_t peek (void *buffer, size_t len);
27 virtual off_t tell (); /* not implemented */
28 virtual off_t seek (off_t where, io_stream_seek_t whence);
29 virtual int error ();
30 virtual const char *next_file_name () { return NULL; };
31 virtual int set_mtime (time_t);
32 virtual time_t get_mtime ();
33 virtual mode_t get_mode ();
34 virtual size_t get_size () {return 0;};
35 virtual ~compress_zstd ();
36 static bool is_zstd (void *buffer, size_t len);
37 virtual void release_original(); /* give up ownership of original io_stream */
39 private:
40 compress_zstd () {};
42 io_stream *original;
43 bool owns_original;
44 int lasterr;
45 void create ();
46 void destroy ();
48 struct private_data {
49 ZSTD_DStream *stream;
50 ZSTD_outBuffer out_block;
51 size_t out_bsz;
52 size_t out_pos;
53 uint64_t total_out;
54 char eof; /* True = found end of compressed data. */
55 ZSTD_inBuffer in_block;
56 size_t in_bsz;
57 size_t in_pos;
58 uint64_t total_in;
59 size_t in_processed;
60 size_t out_processed;
63 struct private_data *state;
66 #endif /* SETUP_COMPRESS_ZSTD_H */