orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rip-nsk <...@git.apache.org>
Subject [GitHub] orc pull request #263: ORC-357: [C++] Use orc::InputStream in getTimezoneByF...
Date Wed, 02 May 2018 17:34:13 GMT
Github user rip-nsk commented on a diff in the pull request:

    https://github.com/apache/orc/pull/263#discussion_r185577344
  
    --- Diff: c++/src/Timezone.cc ---
    @@ -698,40 +694,15 @@ namespace orc {
         if (itr != timezoneCache.end()) {
           return *(itr->second).get();
         }
    -    int in = open(filename.c_str(), O_RDONLY);
    -    if (in == -1) {
    -      std::stringstream buffer;
    -      buffer << "failed to open " << filename << " - " << strerror(errno);
    -      throw TimezoneError(buffer.str());
    -    }
    -    struct stat fileInfo;
    -    if (fstat(in, &fileInfo) == -1) {
    -      std::stringstream buffer;
    -      buffer << "failed to stat " << filename << " - " << strerror(errno);
    -      throw TimezoneError(buffer.str());
    -    }
    -    if ((fileInfo.st_mode & S_IFMT) != S_IFREG) {
    -      std::stringstream buffer;
    -      buffer << "non-file in tzfile reader " << filename;
    -      throw TimezoneError(buffer.str());
    -    }
    -    size_t size = static_cast<size_t>(fileInfo.st_size);
    -    std::vector<unsigned char> buffer(size);
    -    size_t posn = 0;
    -    while (posn < size) {
    -      ssize_t ret = read(in, &buffer[posn], size - posn);
    -      if (ret == -1) {
    -        throw TimezoneError(std::string("Failure to read timezone file ") +
    -                            filename + " - " + strerror(errno));
    -      }
    -      posn += static_cast<size_t>(ret);
    -    }
    -    if (close(in) == -1) {
    -      std::stringstream err;
    -      err << "failed to close " << filename << " - " << strerror(errno);
    -      throw TimezoneError(err.str());
    +    try {
    +      ORC_UNIQUE_PTR<InputStream> file = readFile(filename);
    --- End diff --
    
    'auto' is more suitable here


---

Mime
View raw message