diff options
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 51 | ||||
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 44 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 18 |
5 files changed, 83 insertions, 35 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 32c4ee6..26c9e44 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 2) -set(CMake_VERSION_PATCH 20150529) +set(CMake_VERSION_PATCH 20150601) #set(CMake_VERSION_RC 1) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 0af4688..4698468 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2798,13 +2798,36 @@ namespace { static size_t - cmFileCommandCurlDebugCallback(CURL *, curl_infotype, char *chPtr, + cmFileCommandCurlDebugCallback(CURL *, curl_infotype type, char *chPtr, size_t size, void *data) { cmFileCommandVectorOfChar *vec = static_cast<cmFileCommandVectorOfChar*>(data); - vec->insert(vec->end(), chPtr, chPtr + size); - return size; + switch(type) + { + case CURLINFO_TEXT: + case CURLINFO_HEADER_IN: + case CURLINFO_HEADER_OUT: + vec->insert(vec->end(), chPtr, chPtr + size); + break; + case CURLINFO_DATA_IN: + case CURLINFO_DATA_OUT: + case CURLINFO_SSL_DATA_IN: + case CURLINFO_SSL_DATA_OUT: + { + char buf[128]; + int n = sprintf(buf, "[%" cmIML_INT_PRIu64 " bytes data]\n", + static_cast<cmIML_INT_uint64_t>(size)); + if (n > 0) + { + vec->insert(vec->end(), buf, buf + n); + } + } + break; + default: + break; + } + return 0; } @@ -2963,7 +2986,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) long timeout = 0; long inactivity_timeout = 0; - std::string verboseLog; + std::string logVar; std::string statusVar; bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY"); const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO"); @@ -3008,7 +3031,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) this->SetError("DOWNLOAD missing VAR for LOG."); return false; } - verboseLog = *i; + logVar = *i; } else if(*i == "STATUS") { @@ -3200,7 +3223,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); check_curl_result(res, "DOWNLOAD cannot set follow-redirect option: "); - if(!verboseLog.empty()) + if(!logVar.empty()) { res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); check_curl_result(res, "DOWNLOAD cannot set verbose: "); @@ -3287,22 +3310,10 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) } } - if(!chunkDebug.empty()) + if (!logVar.empty()) { chunkDebug.push_back(0); - if(CURLE_OPERATION_TIMEOUTED == res) - { - std::string output = &*chunkDebug.begin(); - - if(!verboseLog.empty()) - { - this->Makefile->AddDefinition(verboseLog, - &*chunkDebug.begin()); - } - } - - this->Makefile->AddDefinition(verboseLog, - &*chunkDebug.begin()); + this->Makefile->AddDefinition(logVar, &*chunkDebug.begin()); } return true; diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 8069ee2..c88e888 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -88,6 +88,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) IF(POLICY CMP0025) CMAKE_POLICY(SET CMP0025 NEW) ENDIF() +IF(POLICY CMP0056) + CMAKE_POLICY(SET CMP0056 NEW) +ENDIF() #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 6c4a7a6..c834e34 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2674,27 +2674,43 @@ kwsys_stl::string SystemTools::GetLastSystemError() bool SystemTools::RemoveFile(const kwsys_stl::string& source) { #ifdef _WIN32 + kwsys_stl::wstring const& ws = + SystemTools::ConvertToWindowsExtendedPath(source); + if (DeleteFileW(ws.c_str())) + { + return true; + } + DWORD err = GetLastError(); + if (err == ERROR_FILE_NOT_FOUND || + err == ERROR_PATH_NOT_FOUND) + { + return true; + } + if (err != ERROR_ACCESS_DENIED) + { + return false; + } + /* The file may be read-only. Try adding write permission. */ mode_t mode; - if ( !SystemTools::GetPermissions(source, mode) ) + if (!SystemTools::GetPermissions(source, mode) || + !SystemTools::SetPermissions(source, S_IWRITE)) { + SetLastError(err); return false; } - /* Win32 unlink is stupid --- it fails if the file is read-only */ - SystemTools::SetPermissions(source, S_IWRITE); -#endif -#ifdef _WIN32 - bool res = - _wunlink(SystemTools::ConvertToWindowsExtendedPath(source).c_str()) == 0; -#else - bool res = unlink(source.c_str()) != 0 ? false : true; -#endif -#ifdef _WIN32 - if ( !res ) + if (DeleteFileW(ws.c_str()) || + GetLastError() == ERROR_FILE_NOT_FOUND || + GetLastError() == ERROR_PATH_NOT_FOUND) { - SystemTools::SetPermissions(source, mode); + return true; } + /* Try to restore the original permissions. */ + SystemTools::SetPermissions(source, mode); + SetLastError(err); + return false; +#else + return unlink(source.c_str()) == 0 || errno == ENOENT; #endif - return res; } bool SystemTools::RemoveADirectory(const kwsys_stl::string& source) diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 42b6249..15d8eab 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -156,6 +156,24 @@ static bool CheckFileOperations() res = false; } + kwsys_stl::string const testFileMissing(testNewDir + "/testMissingFile.txt"); + if (!kwsys::SystemTools::RemoveFile(testFileMissing)) + { + std::string const& msg = kwsys::SystemTools::GetLastSystemError(); + kwsys_ios::cerr << + "RemoveFile(\"" << testFileMissing << "\") failed: " << msg << "\n"; + res = false; + } + + kwsys_stl::string const testFileMissingDir(testNewDir + "/missing/file.txt"); + if (!kwsys::SystemTools::RemoveFile(testFileMissingDir)) + { + std::string const& msg = kwsys::SystemTools::GetLastSystemError(); + kwsys_ios::cerr << + "RemoveFile(\"" << testFileMissingDir << "\") failed: " << msg << "\n"; + res = false; + } + kwsys::SystemTools::Touch(testNewFile.c_str(), true); if (!kwsys::SystemTools::RemoveADirectory(testNewDir)) { |