6 * file_stats.c - File status query.
8 * Here we implement some commands (SIZE, MDTM) that share the need of calling
9 * stat() over a given file, no matter the fields looked up. It's handy to merge
10 * all of them here so safety checks are not replicated.
15 void file_stats (int type
)
21 if (!path_is_secure(S_arg
)) {
22 send_reply(S_cmd_sk
, "550 Path is insecure.\r\n");
26 err
= stat(expanded_arg(), &st
);
29 send_reply(S_cmd_sk
, "550 Could not stat file.\r\n");
35 gmtime_r(&(st
.st_mtime
), &t
);
36 snprintf(AuxBuf
, LINE_SIZE
,
37 "213 %4d%02d%02d%02d%02d%02d\r\n", t
.tm_year
+ 1900,
38 t
.tm_mon
, t
.tm_mday
, t
.tm_hour
, t
.tm_min
, t
.tm_sec
);
42 snprintf(AuxBuf
, LINE_SIZE
, "213 %lld\r\n",
43 (long long) st
.st_size
);
46 send_reply(S_cmd_sk
, AuxBuf
);