diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 61c6eb34f..e47365a64 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3172,15 +3172,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) return false; } - struct stat st; - if(::stat(filename.c_str(), &st)) - { - std::string errStr = "UPLOAD cannot stat file '"; - errStr += filename + "'."; - this->SetError(errStr); - fclose(fin); - return false; - } + unsigned long file_size = cmsys::SystemTools::FileLength(filename.c_str()); ::CURL *curl; ::curl_global_init(CURL_GLOBAL_DEFAULT); @@ -3270,7 +3262,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) // and give the size of the upload (optional) res = ::curl_easy_setopt(curl, - CURLOPT_INFILESIZE, static_cast(st.st_size)); + CURLOPT_INFILESIZE, static_cast(file_size)); check_curl_result(res, "UPLOAD cannot set input file size: "); res = ::curl_easy_perform(curl); diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index ac26503c6..6fd6ab7b4 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -33,15 +33,13 @@ std::string cmTimestamp::CurrentTime( std::string cmTimestamp::FileModificationTime(const char* path, const std::string& formatString, bool utcFlag) { - struct stat info; - memset(&info, 0, sizeof(info)); - - if(stat(path, &info) != 0) + if(!cmsys::SystemTools::FileExists(path)) { return std::string(); } - return CreateTimestampFromTimeT(info.st_mtime, formatString, utcFlag); + time_t mtime = cmsys::SystemTools::ModifiedTime(path); + return CreateTimestampFromTimeT(mtime, formatString, utcFlag); } //----------------------------------------------------------------------------