svnno****@sourc*****
svnno****@sourc*****
2012年 2月 8日 (水) 00:10:59 JST
Revision: 4839 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4839 Author: maya Date: 2012-02-08 00:10:59 +0900 (Wed, 08 Feb 2012) Log Message: ----------- Kermit で受信する、Attribute Creation Date の対応フォーマットを追加 2桁の西暦年の処理は RFC 2626 参照し、RFC 2822 の 49/50 を境目とする方法を選択した Modified Paths: -------------- trunk/teraterm/ttpfile/kermit.c -------------- next part -------------- Modified: trunk/teraterm/ttpfile/kermit.c =================================================================== --- trunk/teraterm/ttpfile/kermit.c 2012-02-07 15:04:24 UTC (rev 4838) +++ trunk/teraterm/ttpfile/kermit.c 2012-02-07 15:10:59 UTC (rev 4839) @@ -690,17 +690,90 @@ kv->FileAttrFlag |= KMT_ATTR_TYPE; kv->FileType = (str[0] == 'A' ? TRUE : FALSE); break; - case '#': // File creation date "20100226 12:23:45" + case '#': // File creation date "[yy]yymmdd[ hh:mm[:ss]]" kv->FileAttrFlag |= KMT_ATTR_TIME; memset(&tm, 0, sizeof(tm)); - if ( sscanf(str, "%04d%02d%02d %02d:%02d:%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { - kv->FileTime = time(NULL); - - } else { - tm.tm_year -= 1900; // 1900- - tm.tm_mon -= 1; // 0 - 11 - kv->FileTime = mktime(&tm); + switch (strlen(str)) { + case 17: + if ( sscanf(str, "%04d%02d%02d %02d:%02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { + kv->FileTime = time(NULL); + } else { + tm.tm_year -= 1900; // 1900- + tm.tm_mon -= 1; // 0 - 11 + kv->FileTime = mktime(&tm); + } + break; + case 14: + if ( sscanf(str, "%04d%02d%02d %02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min) < 5 ) { + kv->FileTime = time(NULL); + } else { + tm.tm_year -= 1900; // 1900- + tm.tm_mon -= 1; // 0 - 11 + tm.tm_sec = 0; + kv->FileTime = mktime(&tm); + } + break; + case 8: + if ( sscanf(str, "%04d%02d%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday) < 3 ) { + kv->FileTime = time(NULL); + } else { + tm.tm_year -= 1900; // 1900- + tm.tm_mon -= 1; // 0 - 11 + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + kv->FileTime = mktime(&tm); + } + break; + case 15: + if ( sscanf(str, "%02d%02d%02d %02d:%02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { + kv->FileTime = time(NULL); + } else { + if (tm.tm_year <= 49) { + tm.tm_year += 100; // 1900- + } + tm.tm_mon -= 1; // 0 - 11 + kv->FileTime = mktime(&tm); + } + break; + case 12: + if ( sscanf(str, "%02d%02d%02d %02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min) < 5 ) { + kv->FileTime = time(NULL); + } else { + if (tm.tm_year <= 49) { + tm.tm_year += 100; // 1900- + } + tm.tm_mon -= 1; // 0 - 11 + tm.tm_sec = 0; + kv->FileTime = mktime(&tm); + } + break; + case 6: + if ( sscanf(str, "%02d%02d%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday) < 3 ) { + kv->FileTime = time(NULL); + } else { + if (tm.tm_year <= 49) { + tm.tm_year += 100; // 1900- + } + tm.tm_mon -= 1; // 0 - 11 + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + kv->FileTime = mktime(&tm); + } + break; + default: + kv->FileTime = time(NULL); } break; case ',': // File attribute "664"