}
///////////////////////////////////////////////////////////////////////////////
+// readALL
+///////////////////////////////////////////////////////////////////////////////
static void readALL_(FILE *fp, std::vector<char> &buf)
{
int iRet = fseek(fp, 0L, SEEK_END);
void readAll(const char *path, std::vector<char> &buf)
{
- /*
- std::ifstream io(path, std::ios::binary);
- if(!io){
- return;
+ FILE* fp = fopen(path, "rb");
+ if(fp){
+ readALL_(fp, buf);
+ fclose(fp);
}
- io.seekg(0, std::fstream::end);
- unsigned int eofPos = io.tellg();
- io.clear();
- io.seekg(0, std::fstream::beg);
- unsigned int begPos = io.tellg();
- unsigned int size = eofPos - begPos;
- io.read(&buf[0], buf.size());
- */
+}
- FILE* fp = fopen(path, "rb");
+#ifdef _WIN32
+void readAll(const wchar_t *path, std::vector<char> &buf)
+{
+ FILE* fp = _wfopen(path, L"rb");
if(fp){
readALL_(fp, buf);
fclose(fp);
}
}
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// FileWriter
+///////////////////////////////////////////////////////////////////////////////
+FileWriter::FileWriter(const char *path)
+{
+ io_=fopen(path, "wb");
+}
+
+FileWriter::FileWriter(const wchar_t *path)
+{
+ io_=_wfopen(path, L"wb");
+}
+
+FileWriter::~FileWriter()
+{
+ fclose(io_);
+}
+
+void FileWriter::write(const char *buf, unsigned int size)
+{
+ fwrite(buf, size, 1, io_);
+}
+
} // namespace binary
} // namespace meshio