summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-11-26 21:00:57 +0000
committerCarl Hetherington <cth@carlh.net>2013-11-26 21:00:57 +0000
commit6a401d409524d9809760410a51cf3adada77794a (patch)
tree2660a10140cd32e149bdbe89c244c3a12bfd50f2
parent7f43926bf2d2d9b4a480ddd4e006736056dcbb22 (diff)
Attempt to fix file size reporting from asdcplib on Win32.
-rw-r--r--asdcplib/src/KM_fileio.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/asdcplib/src/KM_fileio.cpp b/asdcplib/src/KM_fileio.cpp
index 1b132deb..06076bf8 100644
--- a/asdcplib/src/KM_fileio.cpp
+++ b/asdcplib/src/KM_fileio.cpp
@@ -109,9 +109,18 @@ do_stat(const char* path, fstat_t* stat_info)
#ifdef KM_WIN32
UINT prev = ::SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
- if ( _stati64(path, stat_info) == (__int64)-1 )
+ 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;
+ }
+
+ if ( _wstati64(buffer, stat_info) == (__int64)-1 )
result = Kumu::RESULT_FILEOPEN;
+ delete[] buffer;
+
::SetErrorMode( prev );
#else
if ( stat(path, stat_info) == -1L )
@@ -695,7 +704,6 @@ Kumu::FileReader::OpenRead(const char* filename) const
delete[] buffer;
return Kumu::RESULT_FAIL;
}
-
const_cast<FileReader*>(this)->m_Handle = ::CreateFileW(buffer,
(GENERIC_READ), // open for reading
FILE_SHARE_READ, // share for reading