Skip to content

Commit

Permalink
Encoding: Replace some system calls with kwsys calls which handle uni…
Browse files Browse the repository at this point in the history
…code.
  • Loading branch information
Clinton Stimpson committed Jul 1, 2014
1 parent 949715f commit 9571214
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
12 changes: 2 additions & 10 deletions Source/cmFileCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3172,15 +3172,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> 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);
Expand Down Expand Up @@ -3270,7 +3262,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)

// and give the size of the upload (optional)
res = ::curl_easy_setopt(curl,
CURLOPT_INFILESIZE, static_cast<long>(st.st_size));
CURLOPT_INFILESIZE, static_cast<long>(file_size));
check_curl_result(res, "UPLOAD cannot set input file size: ");

res = ::curl_easy_perform(curl);
Expand Down
8 changes: 3 additions & 5 deletions Source/cmTimestamp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//----------------------------------------------------------------------------
Expand Down

0 comments on commit 9571214

Please sign in to comment.