diff --git a/ChangeLog b/ChangeLog index eb759c5d2..66dedfe47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-01-30 Moritz Bunkus + + * mmg: bug fix: Overwriting a chapter file did not erase the + previous file. So if the previous file was bigger than the current + chapters then garbage remained at the end of the file. + 2005-01-20 Moritz Bunkus * mmg: bug fix: The "stretch" input box tooltip was wrong. The diff --git a/src/base64tool.cpp b/src/base64tool.cpp index 9fbeebf70..70c4f9f26 100644 --- a/src/base64tool.cpp +++ b/src/base64tool.cpp @@ -82,7 +82,7 @@ main(int argc, } try { - out = new mm_file_io_c(argv[3], MODE_WRITE); + out = new mm_file_io_c(argv[3], MODE_CREATE); } catch(...) { mxerror(_("The file '%s' could not be opened for writing (%d, %s).\n"), argv[3], errno, strerror(errno)); diff --git a/src/common/mm_io.cpp b/src/common/mm_io.cpp index 927720b79..169bcdb5f 100644 --- a/src/common/mm_io.cpp +++ b/src/common/mm_io.cpp @@ -44,13 +44,13 @@ mm_file_io_c::mm_file_io_c(const string &path, cmode = "rb"; break; case MODE_WRITE: - cmode = "wb"; + cmode = "a+b"; break; case MODE_CREATE: - cmode = "wb+"; + cmode = "w+b"; break; case MODE_SAFE: - cmode = "r+b"; + cmode = "rb"; break; default: throw 0; @@ -122,7 +122,7 @@ mm_file_io_c::truncate(int64_t pos) { return ftruncate(fileno((FILE *)file), pos); } -#else // SYS_UNIX +#else // SYS_WINDOWS HANDLE CreateFileUtf8(LPCSTR lpFileName, diff --git a/src/extract/attachments.cpp b/src/extract/attachments.cpp index e8751dca7..611827499 100644 --- a/src/extract/attachments.cpp +++ b/src/extract/attachments.cpp @@ -130,7 +130,7 @@ handle_attachments(KaxAttachments *atts) { "is written to '%s'.\n"), id, type.c_str(), size, tracks[k].out_name); try { - out = new mm_file_io_c(tracks[k].out_name, MODE_WRITE); + out = new mm_file_io_c(tracks[k].out_name, MODE_CREATE); } catch (...) { mxerror(_("The file '%s' could not be opened for writing " "(%d, %s).\n"), diff --git a/src/extract/tracks.cpp b/src/extract/tracks.cpp index f24898ea5..bafee50bd 100644 --- a/src/extract/tracks.cpp +++ b/src/extract/tracks.cpp @@ -1278,7 +1278,7 @@ write_all_cuesheets(KaxChapters &chapters, cue_file_name += ".cue"; try { - out = new mm_file_io_c(cue_file_name.c_str(), MODE_WRITE); + out = new mm_file_io_c(cue_file_name.c_str(), MODE_CREATE); } catch(...) { mxerror(_("The file '%s' could not be opened for writing (%s).\n"), cue_file_name.c_str(), strerror(errno)); diff --git a/src/mmg/tab_chapters.cpp b/src/mmg/tab_chapters.cpp index da81ef91c..45e0b6210 100644 --- a/src/mmg/tab_chapters.cpp +++ b/src/mmg/tab_chapters.cpp @@ -778,7 +778,7 @@ tab_chapters::save() { wxString err; try { - out = new mm_file_io_c(wxMB(file_name), MODE_WRITE); + out = new mm_file_io_c(wxMB(file_name), MODE_CREATE); #if defined(SYS_WINDOWS) out->use_dos_style_newlines(true); #endif