6 ///////////////////////////////////////////////////////////////////////////////
8 ///////////////////////////////////////////////////////////////////////////////
9 FileReader::FileReader(const char *path)
10 : io_(path, std::ios::binary), pos_(0), eof_(false)
14 FileReader::~FileReader()
18 unsigned int FileReader::read(char *buf, unsigned int size)
32 unsigned int FileReader::getPos()const
37 bool FileReader::isEnd()const
42 ///////////////////////////////////////////////////////////////////////////////
44 ///////////////////////////////////////////////////////////////////////////////
45 MemoryReader::MemoryReader(const char *buf, unsigned int size)
46 : buf_(buf), size_(size), pos_(0)
50 MemoryReader::~MemoryReader()
54 unsigned int MemoryReader::read(char *buf, unsigned int size)
59 std::copy(&buf_[pos_], &buf_[pos_+size], buf);
64 unsigned int MemoryReader::getPos()const
69 bool MemoryReader::isEnd()const
74 ///////////////////////////////////////////////////////////////////////////////
75 static void readALL_(FILE *fp, std::vector<char> &buf)
77 int iRet = fseek(fp, 0L, SEEK_END);
83 iRet = fgetpos(fp, &pos);
88 iRet = fseek(fp, 0L, SEEK_SET);
93 buf.resize((long)pos);
94 fread(&buf[0], (long)pos, 1, fp);
97 void readAll(const char *path, std::vector<char> &buf)
100 std::ifstream io(path, std::ios::binary);
104 io.seekg(0, std::fstream::end);
105 unsigned int eofPos = io.tellg();
107 io.seekg(0, std::fstream::beg);
108 unsigned int begPos = io.tellg();
109 unsigned int size = eofPos - begPos;
110 io.read(&buf[0], buf.size());
113 FILE* fp = fopen(path, "rb");
120 } // namespace binary
121 } // namespace meshio