Skip to content
Snippets Groups Projects
Commit dd037684 authored by Aaron's avatar Aaron
Browse files

expand now handles gzipped files w/o .gz extension.

parent bb393ba8
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,9 @@ UTILITIES_DIR = ../../utils/ ...@@ -4,7 +4,9 @@ UTILITIES_DIR = ../../utils/
# ------------------- # -------------------
# define our includes # define our includes
# ------------------- # -------------------
INCLUDES = -I$(UTILITIES_DIR)/lineFileUtilities/ -I$(UTILITIES_DIR)/gzstream/ -I$(UTILITIES_DIR)/fileType/ INCLUDES = -I$(UTILITIES_DIR)/lineFileUtilities/ \
-I$(UTILITIES_DIR)/gzstream/ \
-I$(UTILITIES_DIR)/fileType/
# ---------------------------------- # ----------------------------------
# define our source and object files # define our source and object files
......
...@@ -25,45 +25,20 @@ TabFile::TabFile(const string &tabFile) ...@@ -25,45 +25,20 @@ TabFile::TabFile(const string &tabFile)
TabFile::~TabFile(void) { TabFile::~TabFile(void) {
} }
void TabFile::Open(void) { void TabFile::Open(void) {
if (_tabFile == "stdin" || _tabFile == "-") { if (_tabFile == "stdin" || _tabFile == "-") {
_tabStream = &cin; _tabStream = &cin;
} }
else { else {
size_t foundPos; _tabStream = new ifstream(_tabFile.c_str(), ios::in);
foundPos = _tabFile.find_last_of(".gz");
// is this a GZIPPED TAB file? if( isGzipFile(_tabStream) ) {
if (foundPos == _tabFile.size() - 1) { delete _tabStream;
igzstream tabs(_tabFile.c_str(), ios::in); _tabStream = new igzstream(_tabFile.c_str(), ios::in);
if ( !tabs ) {
cerr << "Error: The requested file (" << _tabFile << ") could not be opened. Exiting!" << endl;
exit (1);
}
else {
// if so, close it (this was just a test)
tabs.close();
// now set a pointer to the stream so that we
// can read the file later on.
_tabStream = new igzstream(_tabFile.c_str(), ios::in);
}
} }
// not GZIPPED. if ( !(_tabStream->good()) ) {
else { cerr << "Error: The requested file (" << _tabFile << ") could not be opened. Exiting!" << endl;
exit (1);
ifstream tabs(_tabFile.c_str(), ios::in);
// can we open the file?
if ( !tabs ) {
cerr << "Error: The requested file (" << _tabFile << ") could not be opened. Exiting!" << endl;
exit (1);
}
else {
// if so, close it (this was just a test)
tabs.close();
// now set a pointer to the stream so that we
// can read the file later on.
_tabStream = new ifstream(_tabFile.c_str(), ios::in);
}
} }
} }
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define TABFILE_H #define TABFILE_H
#include "gzstream.h" #include "gzstream.h"
#include "fileType.h"
#include <vector> #include <vector>
#include <string> #include <string>
#include <iostream> #include <iostream>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment