From d04995bac8bc283f33224d63715c704ceede8beb Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Thu, 21 Jun 2007 21:04:50 +0000 Subject: [PATCH] Fixed text_file_writer.h on Linux and made it use fstream on Win32 as well. Originally committed to SVN as r1284. --- aegisub/text_file_writer.cpp | 21 +-------------------- aegisub/text_file_writer.h | 9 ++------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/aegisub/text_file_writer.cpp b/aegisub/text_file_writer.cpp index ad60f3da0..ed9815a39 100644 --- a/aegisub/text_file_writer.cpp +++ b/aegisub/text_file_writer.cpp @@ -78,17 +78,10 @@ TextFileWriter::~TextFileWriter() { void TextFileWriter::Open() { // Open file if (open) return; -#ifdef WIN32 - file = _tfopen(filename.c_str(), _T("wb")); - if (!file) { - throw _T("Failed opening file for writing."); - } -#else - file.open(filename.mb_str(wxConvLocal),std::ios::out | std::ios::binary | std::ios::trunc); + file.open(wxFNCONV(filename),std::ios::out | std::ios::binary | std::ios::trunc); if (!file.is_open()) { throw _T("Failed opening file for writing."); } -#endif open = true; // Set encoding @@ -100,11 +93,7 @@ void TextFileWriter::Open() { // Close file void TextFileWriter::Close() { if (!open) return; -#ifdef WIN32 - fclose(file); -#else file.close(); -#endif open = false; if (customConv) delete conv; } @@ -133,11 +122,7 @@ void TextFileWriter::WriteLineToFile(wxString line,bool addLineBreak) { if (!buf.data()) return; size_t len = wcslen(buf.data()); -#ifdef WIN32 - fwrite(buf.data(), sizeof(wchar_t), len, file); -#else file.write((const char*)buf.data(),len*sizeof(wchar_t)); -#endif } // 8-bit @@ -146,11 +131,7 @@ void TextFileWriter::WriteLineToFile(wxString line,bool addLineBreak) { if (!buf.data()) return; size_t len = strlen(buf.data()); -#ifdef WIN32 - fwrite(buf.data(), 1, len, file); -#else file.write(buf.data(),len); -#endif } } diff --git a/aegisub/text_file_writer.h b/aegisub/text_file_writer.h index 22e5f0d0a..1ca6d1e40 100644 --- a/aegisub/text_file_writer.h +++ b/aegisub/text_file_writer.h @@ -41,9 +41,7 @@ /////////// // Headers #include -#ifdef WIN32 -#include -#endif +#include ///////// @@ -52,11 +50,8 @@ class TextFileWriter { private: wxString filename; wxString encoding; -#ifdef WIN32 - FILE *file; -#else std::ofstream file; -#endif + wxMBConv *conv; bool customConv; bool open;