diff options
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e2adabe..3f03b51 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -30,7 +30,6 @@ # include "cmLocale.h" # include <cm_libarchive.h> #endif -#include <cmsys/stl/algorithm> #include <cmsys/FStream.hxx> #include <cmsys/Terminal.h> @@ -556,25 +555,6 @@ void cmSystemTools::ParseUnixCommandLine(const char* command, argv.Store(args); } -std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, - int shell_flags) -{ - char local_buffer[1024]; - char* buffer = local_buffer; - int size = cmsysSystem_Shell_GetArgumentSizeForWindows(arg, shell_flags); - if(size > 1024) - { - buffer = new char[size]; - } - cmsysSystem_Shell_GetArgumentForWindows(arg, buffer, shell_flags); - std::string result(buffer); - if(buffer != local_buffer) - { - delete [] buffer; - } - return result; -} - std::vector<std::string> cmSystemTools::ParseArguments(const char* command) { std::vector<std::string> args; @@ -969,8 +949,9 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) Try multiple times since we may be racing against another process creating/opening the destination file just before our MoveFileEx. */ WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry(); - while(!MoveFileExW(cmsys::Encoding::ToWide(oldname).c_str(), - cmsys::Encoding::ToWide(newname).c_str(), + while(!MoveFileExW( + SystemTools::ConvertToWindowsExtendedPath(oldname).c_str(), + SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), MOVEFILE_REPLACE_EXISTING) && --retry.Count) { DWORD last_error = GetLastError(); @@ -981,12 +962,14 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) return false; } DWORD attrs = - GetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str()); + GetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(newname).c_str()); if((attrs != INVALID_FILE_ATTRIBUTES) && (attrs & FILE_ATTRIBUTE_READONLY)) { // Remove the read-only attribute from the destination file. - SetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str(), + SetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(newname).c_str(), attrs & ~FILE_ATTRIBUTE_READONLY); } else @@ -1498,7 +1481,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, { #if defined(CMAKE_BUILD_WITH_CMAKE) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmsys::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); + cmsys::ofstream fout(outFileName, std::ios::out | std::ios::binary); if(!fout) { std::string e = "Cannot open output file \""; @@ -1721,7 +1704,7 @@ bool extract_tar(const char* outFileName, bool verbose, static_cast<void>(localeRAII); struct archive* a = archive_read_new(); struct archive *ext = archive_write_disk_new(); - archive_read_support_compression_all(a); + archive_read_support_filter_all(a); archive_read_support_format_all(a); struct archive_entry *entry; int r = cm_archive_read_open_file(a, outFileName, 10240); @@ -1808,7 +1791,7 @@ bool extract_tar(const char* outFileName, bool verbose, } archive_write_free(ext); archive_read_close(a); - archive_read_finish(a); + archive_read_free(a); return r == ARCHIVE_EOF || r == ARCHIVE_OK; } } @@ -1975,11 +1958,11 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle hFrom = - CreateFileW(cmsys::Encoding::ToWide(fromFile).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fromFile).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); cmSystemToolsWindowsHandle hTo = - CreateFileW(cmsys::Encoding::ToWide(toFile).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(toFile).c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!hFrom || !hTo) { @@ -2031,7 +2014,7 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if(!h) { @@ -2058,7 +2041,7 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!h) { @@ -2955,3 +2938,12 @@ bool cmSystemTools::StringToLong(const char* str, long* value) *value = strtol(str, &endp, 10); return (*endp == '\0') && (endp != str) && (errno == 0); } + +//---------------------------------------------------------------------------- +bool cmSystemTools::StringToULong(const char* str, unsigned long* value) +{ + errno = 0; + char *endp; + *value = strtoul(str, &endp, 10); + return (*endp == '\0') && (endp != str) && (errno == 0); +} |