MCPcopy Create free account
hub / github.com/ceph/ceph / invoke_date

Method invoke_date

src/include/invoke_date.cc:24–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include <errno.h>
23
24int utime_t::invoke_date(const std::string& date_str, utime_t *result) {
25 char buf[256];
26
27 SubProcess bin_date("/bin/date", SubProcess::CLOSE, SubProcess::PIPE,
28 SubProcess::KEEP);
29 bin_date.add_cmd_args("-d", date_str.c_str(), "+%s %N", NULL);
30
31 int r = bin_date.spawn();
32 if (r < 0) return r;
33
34 ssize_t n = safe_read(bin_date.get_stdout(), buf, sizeof(buf));
35
36 r = bin_date.join();
37 if (r || n <= 0) return -EINVAL;
38
39 uint64_t epoch, nsec;
40 std::istringstream iss(buf);
41
42 iss >> epoch;
43 iss >> nsec;
44
45 *result = utime_t(epoch, nsec);
46
47 return 0;
48}

Callers

nothing calls this directly

Calls 7

safe_readFunction · 0.85
utime_tClass · 0.70
add_cmd_argsMethod · 0.45
c_strMethod · 0.45
spawnMethod · 0.45
get_stdoutMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected