mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
Use cmFileTimes instead of cmSystemToolsFileTime interface
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include "cmCryptoHash.h"
|
#include "cmCryptoHash.h"
|
||||||
#include "cmDuration.h"
|
#include "cmDuration.h"
|
||||||
#include "cmFSPermissions.h"
|
#include "cmFSPermissions.h"
|
||||||
|
#include "cmFileTimes.h"
|
||||||
#include "cmGeneratedFileStream.h"
|
#include "cmGeneratedFileStream.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
@@ -388,7 +389,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
|
|||||||
}
|
}
|
||||||
/* If it is not a symlink then do a plain copy */
|
/* If it is not a symlink then do a plain copy */
|
||||||
else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
|
else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
|
||||||
cmSystemTools::CopyFileTime(inFile, filePath))) {
|
cmFileTimes::Copy(inFile, filePath))) {
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
"Problem copying file: " << inFile << " -> "
|
"Problem copying file: " << inFile << " -> "
|
||||||
<< filePath << std::endl);
|
<< filePath << std::endl);
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "cmFileCopier.h"
|
#include "cmFileCopier.h"
|
||||||
#include "cmFileInstaller.h"
|
#include "cmFileInstaller.h"
|
||||||
#include "cmFileLockPool.h"
|
#include "cmFileLockPool.h"
|
||||||
|
#include "cmFileTimes.h"
|
||||||
#include "cmGeneratorExpression.h"
|
#include "cmGeneratorExpression.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmHexFileConverter.h"
|
#include "cmHexFileConverter.h"
|
||||||
@@ -52,8 +53,6 @@
|
|||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class cmSystemToolsFileTime;
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// libcurl doesn't support file:// urls for unicode filenames on Windows.
|
// libcurl doesn't support file:// urls for unicode filenames on Windows.
|
||||||
// Convert string from UTF-8 to ACP if this is a file:// URL.
|
// Convert string from UTF-8 to ACP if this is a file:// URL.
|
||||||
@@ -1114,8 +1113,7 @@ bool cmFileCommand::HandleRPathChangeCommand(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool success = true;
|
bool success = true;
|
||||||
cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
|
cmFileTimes const ft(file);
|
||||||
bool have_ft = cmSystemTools::FileTimeGet(file, ft);
|
|
||||||
std::string emsg;
|
std::string emsg;
|
||||||
bool changed;
|
bool changed;
|
||||||
if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) {
|
if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) {
|
||||||
@@ -1139,11 +1137,8 @@ bool cmFileCommand::HandleRPathChangeCommand(
|
|||||||
message += "\"";
|
message += "\"";
|
||||||
this->Makefile->DisplayStatus(message, -1);
|
this->Makefile->DisplayStatus(message, -1);
|
||||||
}
|
}
|
||||||
if (have_ft) {
|
ft.Store(file);
|
||||||
cmSystemTools::FileTimeSet(file, ft);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cmSystemTools::FileTimeDelete(ft);
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1182,8 +1177,7 @@ bool cmFileCommand::HandleRPathRemoveCommand(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool success = true;
|
bool success = true;
|
||||||
cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
|
cmFileTimes const ft(file);
|
||||||
bool have_ft = cmSystemTools::FileTimeGet(file, ft);
|
|
||||||
std::string emsg;
|
std::string emsg;
|
||||||
bool removed;
|
bool removed;
|
||||||
if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) {
|
if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) {
|
||||||
@@ -1203,11 +1197,8 @@ bool cmFileCommand::HandleRPathRemoveCommand(
|
|||||||
message += "\"";
|
message += "\"";
|
||||||
this->Makefile->DisplayStatus(message, -1);
|
this->Makefile->DisplayStatus(message, -1);
|
||||||
}
|
}
|
||||||
if (have_ft) {
|
ft.Store(file);
|
||||||
cmSystemTools::FileTimeSet(file, ft);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cmSystemTools::FileTimeDelete(ft);
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "cmFSPermissions.h"
|
#include "cmFSPermissions.h"
|
||||||
#include "cmFileCommand.h"
|
#include "cmFileCommand.h"
|
||||||
|
#include "cmFileTimes.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmsys/Directory.hxx"
|
#include "cmsys/Directory.hxx"
|
||||||
@@ -75,20 +76,15 @@ bool cmFileCopier::SetPermissions(const std::string& toFile,
|
|||||||
|
|
||||||
// Writing to an NTFS alternate stream changes the modification
|
// Writing to an NTFS alternate stream changes the modification
|
||||||
// time, so we need to save and restore its original value.
|
// time, so we need to save and restore its original value.
|
||||||
cmSystemToolsFileTime* file_time_orig = cmSystemTools::FileTimeNew();
|
cmFileTimes file_time_orig(toFile);
|
||||||
cmSystemTools::FileTimeGet(toFile, file_time_orig);
|
{
|
||||||
|
cmsys::ofstream permissionStream(mode_t_adt_filename.c_str());
|
||||||
cmsys::ofstream permissionStream(mode_t_adt_filename.c_str());
|
if (permissionStream) {
|
||||||
|
permissionStream << std::oct << permissions << std::endl;
|
||||||
if (permissionStream) {
|
}
|
||||||
permissionStream << std::oct << permissions << std::endl;
|
permissionStream.close();
|
||||||
}
|
}
|
||||||
|
file_time_orig.Store(toFile);
|
||||||
permissionStream.close();
|
|
||||||
|
|
||||||
cmSystemTools::FileTimeSet(toFile, file_time_orig);
|
|
||||||
|
|
||||||
cmSystemTools::FileTimeDelete(file_time_orig);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -614,7 +610,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile,
|
|||||||
if (cmSystemTools::GetPermissions(toFile, perm)) {
|
if (cmSystemTools::GetPermissions(toFile, perm)) {
|
||||||
cmSystemTools::SetPermissions(toFile, perm | mode_owner_write);
|
cmSystemTools::SetPermissions(toFile, perm | mode_owner_write);
|
||||||
}
|
}
|
||||||
if (!cmSystemTools::CopyFileTime(fromFile, toFile)) {
|
if (!cmFileTimes::Copy(fromFile, toFile)) {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << this->Name << " cannot set modification time on \"" << toFile
|
e << this->Name << " cannot set modification time on \"" << toFile
|
||||||
<< "\"";
|
<< "\"";
|
||||||
|
Reference in New Issue
Block a user