9 static const char rcsid[] __attribute__((used)) =
"$Id: GZCSVPathReader.cpp 1653 2016-02-28 19:54:59Z sella $";
11 #include "GZCSVFileReader.h"
12 #include "GZCSVPathReader.h"
14 #include <sys/types.h>
18 using namespace sella::file;
38 DIR * directory = ::opendir(this->path.c_str());
40 if (directory == NULL) {
41 THROW(IOException,
"failed to open directory '%s' for reading", this->path.c_str());
43 ::closedir(directory);
46 while (*(this->path.rbegin()) ==
'/') {
47 this->path.erase(this->path.length() - 1, 1);
60 struct dirent ** file;
64 if (data.empty() ==
false) {
70 for (
int i = 0; i < n; i++) {
72 GZCSVFileReader reader(std::string(this->path).append(
"/").append(file[i]->d_name), this->delimiter, this->seperator);
76 }
catch (IOException & e) { }
82 THROW(IOException,
"failed to open directory '%s' for reading", this->path.c_str());
95 size_t size = ::strlen(file->d_name);
A GZIP compressed CSV reader.
void read(std::vector< std::vector< std::string >> &data) THROWS(IOException)
void close(bool unlink=false) NO_EXCEPTIONS
void read(std::vector< std::vector< std::string >> &data) THROWS(IOException)
static int filter(const struct dirent *file) NO_EXCEPTIONS
GZCSVPathReader(const std::string &path, char delimiter=DefaultDelimiter, char seperator=DefaultSeperator) THROWS(IOException)
static const char * FileSuffix
The file suffix for matching files in the directory for reading.