Download chips/yosys/kernel/gzip.h from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/kernel/gzip.h
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/yosys/kernel/gzip.h
-
curl -L -o gzip.h https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/kernel/gzip.h
1.85 kB
| YOSYS_NAMESPACE_BEGIN | |
| namespace Zlib { | |
| } | |
| /* | |
| An output stream that uses a stringbuf to buffer data internally, | |
| using zlib to write gzip-compressed data every time the stream is flushed. | |
| */ | |
| class gzip_ostream : public std::ostream { | |
| public: | |
| gzip_ostream(): std::ostream(nullptr) { | |
| rdbuf(&outbuf); | |
| } | |
| bool open(const std::string &filename) { | |
| return outbuf.open(filename); | |
| } | |
| private: | |
| class obuf : public std::stringbuf { | |
| public: | |
| obuf(); | |
| bool open(const std::string &filename); | |
| virtual int sync() override; | |
| virtual ~obuf(); | |
| private: | |
| static const int buffer_size = 4096; | |
| char buffer[buffer_size]; // Internal buffer for compressed data | |
| Zlib::gzFile gzf = nullptr; // Handle to the gzip file | |
| }; | |
| obuf outbuf; // The stream buffer instance | |
| }; | |
| /* | |
| An input stream that uses zlib to read gzip-compressed data from a file, | |
| buffering the decompressed data internally using its own buffer. | |
| */ | |
| class gzip_istream final : public std::istream { | |
| public: | |
| gzip_istream() : std::istream(&inbuf) {} | |
| bool open(const std::string& filename) { | |
| return inbuf.open(filename); | |
| } | |
| private: | |
| class ibuf final : public std::streambuf { | |
| public: | |
| ibuf() : gzf(nullptr) {} | |
| bool open(const std::string& filename); | |
| virtual ~ibuf(); | |
| protected: | |
| // Called when the buffer is empty and more input is needed | |
| virtual int_type underflow() override; | |
| private: | |
| static const int buffer_size = 8192; | |
| char buffer[buffer_size]; | |
| Zlib::gzFile gzf; | |
| }; | |
| ibuf inbuf; // The stream buffer instance | |
| }; | |
| std::istream* uncompressed(const std::string filename, std::ios_base::openmode mode = std::ios_base::in); | |
| YOSYS_NAMESPACE_END | |