MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleTouchImpl

Function HandleTouchImpl

Source/cmFileCommand.cxx:918–946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

916}
917
918bool HandleTouchImpl(std::vector<std::string> const& args, bool create,
919 cmExecutionStatus& status)
920{
921 // Projects might pass a dynamically generated list of files, and it
922 // could be an empty list. We should not assume there is at least one.
923
924 for (std::string const& arg :
925 cmMakeRange(args).advance(1)) // Get rid of subcommand
926 {
927 std::string tfile = arg;
928 if (!cmsys::SystemTools::FileIsFullPath(tfile)) {
929 tfile =
930 cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', arg);
931 }
932 if (!status.GetMakefile().CanIWriteThisFile(tfile)) {
933 std::string e = cmStrCat("attempted to touch a file: ", tfile,
934 " in a source directory.");
935 status.SetError(e);
936 cmSystemTools::SetFatalErrorOccurred();
937 return false;
938 }
939 if (!cmSystemTools::Touch(tfile, create)) {
940 std::string error = "problem touching file: " + tfile;
941 status.SetError(error);
942 return false;
943 }
944 }
945 return true;
946}
947
948bool HandleTouchCommand(std::vector<std::string> const& args,
949 cmExecutionStatus& status)

Callers 2

HandleTouchCommandFunction · 0.85

Calls 6

cmMakeRangeFunction · 0.85
CanIWriteThisFileMethod · 0.80
cmStrCatFunction · 0.70
advanceMethod · 0.45
GetMakefileMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…