From 0bfad2946dc3da390fed5b58dcf493b55886aa31 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 7 Feb 2008 13:26:16 -0500 Subject: [PATCH] ENH: make sure files are binary for download and make status a pair of value string --- Source/cmFileCommand.cxx | 8 +++++--- Source/cmFileCommand.h | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 3728a5f4f..a30b7048c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1970,7 +1970,7 @@ cmFileCommand::HandleDownloadCommand(std::vector } i++; } - std::ofstream fout(file.c_str()); + std::ofstream fout(file.c_str(), std::ios::binary); if(!fout) { this->SetError("FILE(DOWNLOAD url file TIMEOUT time) can not open " @@ -2008,8 +2008,10 @@ cmFileCommand::HandleDownloadCommand(std::vector curl_easy_cleanup(curl); if(statusVar.size()) { - this->Makefile->AddDefinition(statusVar.c_str(), - curl_easy_strerror(res)); + cmOStringStream result; + result << (int)res << ";\"" << curl_easy_strerror(res) << "\""; + this->Makefile->AddDefinition(statusVar.c_str(), + result.str().c_str()); } curl_global_cleanup(); if(chunkDebug.size()) diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 2631021f5..18f4c8f99 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -150,7 +150,11 @@ public: "DOWNLOAD will download the givin URL to the given file. " "If LOG var is specified a log of the download will be put in var. " "If STATUS var is specified the status of the operation will" - " be put in var. If TIMEOUT time is specified, the operation will " + " be put in var. The status is returned in a list of length 2. " + "The first element is the numeric return value for the operation, " + "and the second element is a string value for the error. A 0 " + "numeric error means no error in the operation. " + "If TIMEOUT time is specified, the operation will " "timeout after time seconds, time can be specified as a float.\n"; }