summaryrefslogtreecommitdiff
path: root/src/KM_fileio.cpp
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-01-14 21:45:19 +0000
committerCarl Hetherington <cth@carlh.net>2019-12-03 16:44:40 +0100
commit0aa969183b97072b238e8aeff89d7b928df02f40 (patch)
tree6476721c6601366a44e9222f891f2ccbca602b31 /src/KM_fileio.cpp
parent85eba79f6dbf1710e2359b4c7c210048895a3872 (diff)
Allow overwrite (i.e. continue) when writing JPEG2000 MXFs.
Diffstat (limited to 'src/KM_fileio.cpp')
-rw-r--r--src/KM_fileio.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index b637fa0..26996f9 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -926,6 +926,44 @@ Kumu::FileWriter::OpenWrite(const std::string& filename)
return Kumu::RESULT_OK;
}
+/** @param filename File name (UTF-8 encoded) */
+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);
+
+ int const wn = MultiByteToWideChar (CP_UTF8, 0, filename, -1, 0, 0);
+ wchar_t* buffer = new wchar_t[wn];
+ if (MultiByteToWideChar (CP_UTF8, 0, filename, -1, buffer, wn) == 0) {
+ delete[] buffer;
+ return Kumu::RESULT_FAIL;
+ }
+
+ m_Handle = ::CreateFileW(buffer,
+ (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
+ );
+
+ delete[] buffer;
+
+ ::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)