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 ///////////////////////////////////////////////////////////////////////////////
76 ///////////////////////////////////////////////////////////////////////////////
77 static void readALL_(FILE *fp, std::vector<char> &buf)
79 int iRet = fseek(fp, 0L, SEEK_END);
85 iRet = fgetpos(fp, &pos);
90 iRet = fseek(fp, 0L, SEEK_SET);
95 buf.resize((long)pos);
96 fread(&buf[0], (long)pos, 1, fp);
99 void readAll(const char *path, std::vector<char> &buf)
101 FILE* fp = fopen(path, "rb");
109 void readAll(const wchar_t *path, std::vector<char> &buf)
111 FILE* fp = _wfopen(path, L"rb");
119 ///////////////////////////////////////////////////////////////////////////////
121 ///////////////////////////////////////////////////////////////////////////////
122 FileWriter::FileWriter(const char *path)
124 io_=fopen(path, "wb");
127 FileWriter::FileWriter(const wchar_t *path)
129 io_=_wfopen(path, L"wb");
132 FileWriter::~FileWriter()
137 void FileWriter::write(const char *buf, unsigned int size)
139 fwrite(buf, size, 1, io_);
143 } // namespace binary
144 } // namespace meshio