7 FileReader::FileReader(const char *path)
8 : io_(path, std::ios::binary), pos_(0), eof_(false)
12 FileReader::~FileReader()
16 unsigned int FileReader::read(char *buf, unsigned int size)
22 size_t read_size=static_cast<size_t>(io_.gcount());
30 unsigned int FileReader::getPos()const
35 bool FileReader::isEnd()const
41 MemoryReader::MemoryReader(const char *buf, unsigned int size)
42 : buf_(buf), size_(size), pos_(0)
46 MemoryReader::~MemoryReader()
50 unsigned int MemoryReader::read(char *buf, unsigned int size)
55 std::copy(&buf_[pos_], &buf_[pos_+size], buf);
60 unsigned int MemoryReader::getPos()const
65 bool MemoryReader::isEnd()const
71 static void readALL_(FILE *fp, std::vector<char> &buf)
73 int iRet = fseek(fp, 0L, SEEK_END);
83 iRet = fseek(fp, 0L, SEEK_SET);
89 iRet=fread(&buf[0], pos, 1, fp);
92 void readAll(const char *path, std::vector<char> &buf)
94 FILE* fp = fopen(path, "rb");
102 void readAll(const wchar_t *path, std::vector<char> &buf)
104 FILE* fp = _wfopen(path, L"rb");
113 FileWriter::FileWriter(const char *path)
115 io_=fopen(path, "wb");
119 FileWriter::FileWriter(const wchar_t *path)
121 io_=_wfopen(path, L"wb");
125 FileWriter::~FileWriter()
130 void FileWriter::write(const char *buf, unsigned int size)
132 fwrite(buf, size, 1, io_);
136 } // namespace binary
137 } // namespace meshio