diff options
Diffstat (limited to 'fitsy++/allocgz.C')
-rw-r--r-- | fitsy++/allocgz.C | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fitsy++/allocgz.C b/fitsy++/allocgz.C new file mode 100644 index 0000000..b2bbba1 --- /dev/null +++ b/fitsy++/allocgz.C @@ -0,0 +1,25 @@ +// Copyright (C) 1999-2018 +// Smithsonian Astrophysical Observatory, Cambridge, MA, USA +// For conditions of distribution and use, see copyright notice in "copyright" + +#include <unistd.h> +#include "allocgz.h" + +FitsAllocGZ::FitsAllocGZ(const char* fn) +{ + parse(fn); + if (!valid_) + return; + + // we need the 'b' for windows... + if (!strncmp(pName_, "stdin", 5) || + !strncmp(pName_, "STDIN", 5) || + !strncmp(pName_, "-", 1)) + stream_ = gzdopen(dup(STDIN_FILENO), "rb"); + else + stream_ = gzopen(pName_, "rb"); + + valid_ = stream_ ? 1 : 0; +} + + |