mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-08 04:01:25 +00:00
gzip: back to pointers
This commit is contained in:
parent
a8a5463f57
commit
7aefd4b226
5 changed files with 20 additions and 20 deletions
|
@ -100,17 +100,17 @@ gzip_istream::ibuf::~ibuf() {
|
|||
|
||||
// Takes a successfully opened ifstream. If it's gzipped, returns an istream. Otherwise,
|
||||
// returns the original ifstream, rewound to the start.
|
||||
std::istream& uncompressed(const std::string filename, std::ios_base::openmode mode) {
|
||||
std::ifstream& f = *new std::ifstream();
|
||||
f.open(filename, mode);
|
||||
if (f.fail())
|
||||
std::istream* uncompressed(const std::string filename, std::ios_base::openmode mode) {
|
||||
std::ifstream* f = new std::ifstream();
|
||||
f->open(filename, mode);
|
||||
if (f->fail())
|
||||
return f;
|
||||
// Check for gzip magic
|
||||
unsigned char magic[3];
|
||||
int n = 0;
|
||||
while (n < 3)
|
||||
{
|
||||
int c = f.get();
|
||||
int c = f->get();
|
||||
if (c != EOF) {
|
||||
magic[n] = (unsigned char) c;
|
||||
}
|
||||
|
@ -122,16 +122,16 @@ std::istream& uncompressed(const std::string filename, std::ios_base::openmode m
|
|||
if (magic[2] != 8)
|
||||
log_cmd_error("gzip file `%s' uses unsupported compression type %02x\n",
|
||||
filename.c_str(), unsigned(magic[2]));
|
||||
gzip_istream& s = *new gzip_istream();
|
||||
delete &f;
|
||||
s.open(filename.c_str());
|
||||
gzip_istream* s = new gzip_istream();
|
||||
delete f;
|
||||
s->open(filename.c_str());
|
||||
return s;
|
||||
#else
|
||||
log_cmd_error("File `%s' is a gzip file, but Yosys is compiled without zlib.\n", filename.c_str());
|
||||
#endif // YOSYS_ENABLE_ZLIB
|
||||
} else {
|
||||
f.clear();
|
||||
f.seekg(0, std::ios::beg);
|
||||
f->clear();
|
||||
f->seekg(0, std::ios::beg);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue