1 /**** 2 DIAMOND protein aligner 3 Copyright (C) 2013-2018 Benjamin Buchfink <buchfink@gmail.com> 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 ****/ 18 19 #ifndef FILE_SOURCE_H_ 20 #define FILE_SOURCE_H_ 21 22 #include "stream_entity.h" 23 24 struct FileSource : public StreamEntity 25 { 26 FileSource(const string &file_name); 27 FileSource(const string &file_name, FILE *file); 28 virtual void rewind() override; 29 virtual void seek(size_t pos) override; 30 virtual void seek_forward(size_t n) override; 31 virtual size_t tell() override; 32 virtual size_t read(char *ptr, size_t count) override; 33 virtual void close() override; file_nameFileSource34 virtual const string& file_name() const override 35 { 36 return file_name_; 37 } fileFileSource38 virtual FILE* file() override 39 { 40 return f_; 41 } 42 //void putback(char c); ~FileSourceFileSource43 ~FileSource() 44 {} 45 protected: 46 FILE *f_; 47 const string file_name_; 48 }; 49 50 #endif