From bf42081766a07842050e6dc8c4595d43b5358bbf Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Thu, 22 Jan 2009 11:58:33 +0000 Subject: #BIN upload now preserves the file time. --- call/call.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'call/call.c') diff --git a/call/call.c b/call/call.c index 710f2f5..0e87a17 100644 --- a/call/call.c +++ b/call/call.c @@ -159,6 +159,20 @@ void convert_upper_lower(char *buf, int len) } } + +/* Convert linear UNIX date to a MS-DOS time/date pair. */ + +static char * unix_to_sfbin_date_string(time_t gmt) +{ + + static char buf[9]; + unsigned short s_time, s_date; + + date_unix2dos(((gmt == -1) ? time(0) : gmt), &s_time, &s_date); + sprintf(buf, "%X", ((s_date << 16) + s_time)); + return buf; +} + static int nr_convert_call(char *address, struct full_sockaddr_ax25 *addr) { char buffer[100], *call, *alias; @@ -1833,8 +1847,15 @@ int cmd_call(char *call[], int mode) case 'a': case 'A': { + struct stat statbuf; + time_t file_time = 0L; binup = TRUE; crc = 0; + if (!fstat(uploadfile, &statbuf)) + file_time = statbuf.st_mtime; + else + file_time = time(0); + do { upllen = @@ -1874,9 +1895,11 @@ int cmd_call(char *call[], int mode) 0L, SEEK_SET); sprintf(s, - "#BIN#%ld#$%u#|000000#%s\r", + "#BIN#%ld#|%u#$%s#%s\r", uplsize, - crc, t); + crc, + unix_to_sfbin_date_string(file_time), + t); write(fd, s, strlen(s)); uplpos = 0; -- cgit v1.2.3