# include <sys/utime.h>
#endif
-curl_off_t getfiletime(const char *filename, struct GlobalConfig *global)
+/* Returns 0 on success, non-zero on file problems */
+int getfiletime(const char *filename, struct GlobalConfig *global,
+ curl_off_t *stamp)
{
- curl_off_t result = -1;
+ int rc = 1;
/* Windows stat() may attempt to adjust the unix GMT file time by a daylight
saving time offset and since it's GMT that is bad behavior. When we have
FILETIME ft;
if(GetFileTime(hfile, NULL, NULL, &ft)) {
curl_off_t converted = (curl_off_t)ft.dwLowDateTime
- | ((curl_off_t)ft.dwHighDateTime) << 32;
+ | ((curl_off_t)ft.dwHighDateTime) << 32;
- if(converted < CURL_OFF_T_C(116444736000000000)) {
+ if(converted < CURL_OFF_T_C(116444736000000000))
warnf(global, "Failed to get filetime: underflow");
- }
else {
- result = (converted - CURL_OFF_T_C(116444736000000000)) / 10000000;
+ *stamp = (converted - CURL_OFF_T_C(116444736000000000)) / 10000000;
+ rc = 0;
}
}
else {
#else
struct_stat statbuf;
if(-1 != stat(filename, &statbuf)) {
- result = (curl_off_t)statbuf.st_mtime;
+ *stamp = (curl_off_t)statbuf.st_mtime;
+ rc = 0;
}
- else if(errno != ENOENT) {
+ else
warnf(global, "Failed to get filetime: %s", strerror(errno));
- }
#endif
- return result;
+ return rc;
}
#if defined(HAVE_UTIME) || defined(HAVE_UTIMES) || defined(WIN32)
struct GlobalConfig;
-curl_off_t getfiletime(const char *filename, struct GlobalConfig *global);
+int getfiletime(const char *filename, struct GlobalConfig *global,
+ curl_off_t *stamp);
#if defined(HAVE_UTIME) || defined(HAVE_UTIMES) || \
(defined(WIN32) && (SIZEOF_CURL_OFF_T >= 8))
config->condtime = (curl_off_t)curl_getdate(nextarg, &now);
if(-1 == config->condtime) {
/* now let's see if it is a file name to get the time from instead! */
- curl_off_t filetime = getfiletime(nextarg, global);
- if(filetime >= 0) {
+ curl_off_t filetime;
+ rc = getfiletime(nextarg, global, &filetime);
+ if(!rc)
/* pull the time out from the file */
config->condtime = filetime;
- }
else {
/* failed, remove time condition */
config->timecond = CURL_TIMECOND_NONE;