Commit 83118a93 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'strip-fopen-e-windows'

c58d4b47

 SystemTools: On Windows, strip 'e' from Fopen mode
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !184
parents 44086372 c58d4b47
......@@ -24,6 +24,7 @@
#include KWSYS_HEADER(Encoding.h)
#include KWSYS_HEADER(Encoding.hxx)
#include <algorithm>
#include <fstream>
#include <iostream>
#include <set>
......@@ -892,8 +893,12 @@ const char* SystemTools::GetExecutableExtension()
FILE* SystemTools::Fopen(const std::string& file, const char* mode)
{
#ifdef _WIN32
// Remove any 'e', which is supported on UNIX, but not Windows.
std::wstring trimmedMode = Encoding::ToWide(mode);
trimmedMode.erase(std::remove(trimmedMode.begin(), trimmedMode.end(), L'e'),
trimmedMode.end());
return _wfopen(Encoding::ToWindowsExtendedPath(file).c_str(),
Encoding::ToWide(mode).c_str());
trimmedMode.c_str());
#else
return fopen(file.c_str(), mode);
#endif
......
......@@ -549,7 +549,8 @@ public:
*/
/**
* Open a file considering unicode.
* Open a file considering unicode. On Windows, if 'e' is present in
* mode it is first discarded.
*/
static FILE* Fopen(const std::string& file, const char* mode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment