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

Function HandleTimestampCommand

Source/cmFileCommand.cxx:3102–3148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3100}
3101
3102bool HandleTimestampCommand(std::vector<std::string> const& args,
3103 cmExecutionStatus& status)
3104{
3105 if (args.size() < 3) {
3106 status.SetError("sub-command TIMESTAMP requires at least two arguments.");
3107 return false;
3108 }
3109 if (args.size() > 5) {
3110 status.SetError("sub-command TIMESTAMP takes at most four arguments.");
3111 return false;
3112 }
3113
3114 unsigned int argsIndex = 1;
3115
3116 std::string filename = args[argsIndex++];
3117 if (!cmsys::SystemTools::FileIsFullPath(filename)) {
3118 filename = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/',
3119 filename);
3120 }
3121
3122 std::string const& outputVariable = args[argsIndex++];
3123
3124 std::string formatString;
3125 if (args.size() > argsIndex && args[argsIndex] != "UTC") {
3126 formatString = args[argsIndex++];
3127 }
3128
3129 bool utcFlag = false;
3130 if (args.size() > argsIndex) {
3131 if (args[argsIndex] == "UTC") {
3132 utcFlag = true;
3133 } else {
3134 std::string e =
3135 cmStrCat(" TIMESTAMP sub-command does not recognize option ",
3136 args[argsIndex], '.');
3137 status.SetError(e);
3138 return false;
3139 }
3140 }
3141
3142 cmTimestamp timestamp;
3143 std::string result =
3144 timestamp.FileModificationTime(filename.c_str(), formatString, utcFlag);
3145 status.GetMakefile().AddDefinition(outputVariable, result);
3146
3147 return true;
3148}
3149
3150bool HandleSizeCommand(std::vector<std::string> const& args,
3151 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 7

FileModificationTimeMethod · 0.80
c_strMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
AddDefinitionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…