From 47d48da4bae33a3fb5f9942bc2d5afeb09e714eb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 Feb 2013 19:53:30 +0000 Subject: Try to implement FileWriter::OpenModify on Windows. --- asdcplib/src/KM_fileio.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/asdcplib/src/KM_fileio.cpp b/asdcplib/src/KM_fileio.cpp index 138bc3b4..d48e7554 100644 --- a/asdcplib/src/KM_fileio.cpp +++ b/asdcplib/src/KM_fileio.cpp @@ -831,6 +831,34 @@ Kumu::FileWriter::OpenWrite(const char* filename) return Kumu::RESULT_OK; } +// +Kumu::Result_t +Kumu::FileWriter::OpenModify(const char* filename) +{ + KM_TEST_NULL_STR_L(filename); + m_Filename = filename; + + // suppress popup window on error + UINT prev = ::SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); + + m_Handle = ::CreateFileA(filename, + (GENERIC_WRITE|GENERIC_READ), // open for reading + FILE_SHARE_READ, // share for reading + NULL, // no security + OPEN_ALWAYS, // don't truncate existing + FILE_ATTRIBUTE_NORMAL, // normal file + NULL // no template file + ); + + ::SetErrorMode(prev); + + if ( m_Handle == INVALID_HANDLE_VALUE ) + return Kumu::RESULT_FILEOPEN; + + m_IOVec = new h__iovec; + return Kumu::RESULT_OK; +} + // Kumu::Result_t Kumu::FileWriter::Writev(ui32_t* bytes_written) -- cgit v1.2.3