|
|
@@ -24,6 +24,7 @@
|
|
|
#include KWSYS_HEADER(Encoding.h)
|
|
|
#include KWSYS_HEADER(Encoding.hxx)
|
|
|
|
|
|
+#include <algorithm>
|
|
|
#include <fstream>
|
|
|
#include <iostream>
|
|
|
#include <set>
|
|
|
@@ -49,15 +50,15 @@
|
|
|
# pragma set woff 1375 /* base class destructor not virtual */
|
|
|
#endif
|
|
|
|
|
|
-#include <ctype.h>
|
|
|
-#include <errno.h>
|
|
|
+#include <cctype>
|
|
|
+#include <cerrno>
|
|
|
#ifdef __QNX__
|
|
|
# include <malloc.h> /* for malloc/free on QNX */
|
|
|
#endif
|
|
|
-#include <stdio.h>
|
|
|
-#include <stdlib.h>
|
|
|
-#include <string.h>
|
|
|
-#include <time.h>
|
|
|
+#include <cstdio>
|
|
|
+#include <cstdlib>
|
|
|
+#include <cstring>
|
|
|
+#include <ctime>
|
|
|
|
|
|
#if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__)
|
|
|
# include <strings.h> /* for strcasecmp */
|
|
|
@@ -69,7 +70,7 @@
|
|
|
|
|
|
// support for realpath call
|
|
|
#ifndef _WIN32
|
|
|
-# include <limits.h>
|
|
|
+# include <climits>
|
|
|
# include <pwd.h>
|
|
|
# include <sys/ioctl.h>
|
|
|
# include <sys/time.h>
|
|
|
@@ -80,7 +81,7 @@
|
|
|
# include <sys/param.h>
|
|
|
# include <termios.h>
|
|
|
# endif
|
|
|
-# include <signal.h> /* sigprocmask */
|
|
|
+# include <csignal> /* sigprocmask */
|
|
|
#endif
|
|
|
|
|
|
#ifdef __linux
|
|
|
@@ -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
|
|
|
@@ -2113,7 +2118,7 @@ std::string SystemTools::ConvertToUnixOutputPath(const std::string& path)
|
|
|
ret.erase(pos, 1);
|
|
|
}
|
|
|
// escape spaces and () in the path
|
|
|
- if (ret.find_first_of(" ") != std::string::npos) {
|
|
|
+ if (ret.find_first_of(' ') != std::string::npos) {
|
|
|
std::string result;
|
|
|
char lastch = 1;
|
|
|
for (const char* ch = ret.c_str(); *ch != '\0'; ++ch) {
|
|
|
@@ -2511,8 +2516,8 @@ bool SystemTools::CopyADirectory(const std::string& source,
|
|
|
return false;
|
|
|
}
|
|
|
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
|
|
|
- if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
|
|
|
- strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
|
|
|
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 &&
|
|
|
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
|
|
|
std::string fullPath = source;
|
|
|
fullPath += "/";
|
|
|
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
|
|
@@ -2674,8 +2679,8 @@ bool SystemTools::RemoveADirectory(const std::string& source)
|
|
|
dir.Load(source);
|
|
|
size_t fileNum;
|
|
|
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
|
|
|
- if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
|
|
|
- strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
|
|
|
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 &&
|
|
|
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
|
|
|
std::string fullPath = source;
|
|
|
fullPath += "/";
|
|
|
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
|
|
@@ -3153,7 +3158,7 @@ bool SystemTools::SplitProgramPath(const std::string& in_name,
|
|
|
SystemTools::ConvertToUnixSlashes(dir);
|
|
|
|
|
|
if (!SystemTools::FileIsDirectory(dir)) {
|
|
|
- std::string::size_type slashPos = dir.rfind("/");
|
|
|
+ std::string::size_type slashPos = dir.rfind('/');
|
|
|
if (slashPos != std::string::npos) {
|
|
|
file = dir.substr(slashPos + 1);
|
|
|
dir.resize(slashPos);
|
|
|
@@ -3711,7 +3716,7 @@ std::string SystemTools::GetFilenamePath(const std::string& filename)
|
|
|
std::string fn = filename;
|
|
|
SystemTools::ConvertToUnixSlashes(fn);
|
|
|
|
|
|
- std::string::size_type slash_pos = fn.rfind("/");
|
|
|
+ std::string::size_type slash_pos = fn.rfind('/');
|
|
|
if (slash_pos == 0) {
|
|
|
return "/";
|
|
|
}
|