src/io.cpp
// This constructor for use by NewReaderMaybe().  Doesn't call stat().
// I should clean up this code to avoid redundancy.
This constructor for use by NewReaderMaybe().  Doesn't call stat().
I should clean up this code to avoid redundancy.
This constructor for use by NewReaderMaybe () . Doesn ' t call stat () . I should clean up this code to avoid redundancy .
Reader::Reader(const char *filename, long long int file_size) {
  filename_ = filename;
  file_size_ = file_size;
  remaining_ = file_size;
  fd_ = open(filename, O_RDONLY, 0);
  if (fd_ == -1) {
    fprintf(stderr, "Failed to open \"%s\", errno %i\n", filename, errno);
    if (errno == 24) {
      fprintf(stderr, "errno 24 may indicate too many open files\n");
    }
    exit(-1);
  }
  overflow_size_ = 0;
  byte_pos_ = 0;
  buf_size_ = kBufSize;
  if (remaining_ < buf_size_) buf_size_ = remaining_;
  buf_.reset(new unsigned char[buf_size_]);
  buf_ptr_ = buf_.get();
  end_read_ = buf_.get();
  if (! Refresh()) {
    fprintf(stderr, "Warning: empty file: %s\n", filename);
  }
}
Reader :: Reader ( const char * filename , long long int file_size ) { filename_ = filename ; file_size_ = file_size ; remaining_ = file_size ; fd_ = open ( filename , O_RDONLY , 0 ) ; if ( fd_ == -1 ) { fprintf ( stderr , " \" \" \n " , filename , errno ) ; if ( errno == 24 ) { fprintf ( stderr , " \n " ) ; } exit ( -1 ) ; } overflow_size_ = 0 ; byte_pos_ = 0 ; buf_size_ = kBufSize ; if ( remaining_ < buf_size_ ) buf_size_ = remaining_ ; buf_ . reset ( new unsigned char [ buf_size_ ] ) ; buf_ptr_ = buf_ . get ( ) ; end_read_ = buf_ . get ( ) ; if ( ! Refresh ( ) ) { fprintf ( stderr , " \n " , filename ) ; } }
This constructor for use by NewReaderMaybe().
This constructor for use by NewReaderMaybe () .