[Ttssh2-commit] [5607] SCP 受信時に、ファイルのタイムスタンプを反映するようにした。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2014年 6月 7日 (土) 13:56:18 JST


Revision: 5607
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5607
Author:   maya
Date:     2014-06-07 13:56:18 +0900 (Sat, 07 Jun 2014)
Log Message:
-----------
SCP 受信時に、ファイルのタイムスタンプを反映するようにした。

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/ssh.c
    trunk/ttssh2/ttxssh/ssh.h

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2014-06-06 16:27:23 UTC (rev 5606)
+++ trunk/ttssh2/ttxssh/ssh.c	2014-06-07 04:56:18 UTC (rev 5607)
@@ -56,6 +56,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/utime.h>
 #include <assert.h>
 
 #include <direct.h>
@@ -159,6 +160,8 @@
 		c->scp.progress_window = NULL;
 		c->scp.thread = (HANDLE)-1;
 		c->scp.localfp = NULL;
+		c->scp.filemtime = 0;
+		c->scp.fileatime = 0;
 	}
 	if (type == TYPE_AGENT) {
 		c->agent_msg = buffer_init();
@@ -241,8 +244,17 @@
 
 	if (c->type == TYPE_SCP) {
 		c->scp.state = SCP_CLOSING;
-		if (c->scp.localfp != NULL)
+		if (c->scp.localfp != NULL) {
 			fclose(c->scp.localfp);
+			if (c->scp.dir == FROMREMOTE) {
+				if (c->scp.fileatime > 0 && c->scp.filemtime > 0) {
+					struct _utimbuf filetime;
+					filetime.actime = c->scp.fileatime;
+					filetime.modtime = c->scp.filemtime;
+					_utime(c->scp.localfilefull, &filetime);
+				}
+			}
+		}
 		if (c->scp.progress_window != NULL) {
 			DestroyWindow(c->scp.progress_window);
 			c->scp.progress_window = NULL;
@@ -7298,7 +7310,7 @@
 			_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -t %s", c->scp.remotefile);
 
 		} else {		
-			_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -f %s", c->scp.remotefile);
+			_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -p -f %s", c->scp.remotefile);
 
 		}
 		buffer_put_string(msg, sbuf, strlen(sbuf));
@@ -8008,8 +8020,14 @@
 		}
 
 		if (data[0] == 'T') {  // Tmtime.sec mtime.usec atime.sec atime.usec
-			// TODO: 
+			DWORD mtime, atime;
 
+			sscanf_s(data, "T%ld 0 %ld 0", &mtime, &atime);
+
+			// \x83^\x83C\x83\x80\x83X\x83^\x83\x93\x83v\x82\xF0\x8BL\x98^
+			c->scp.filemtime = mtime;
+			c->scp.fileatime = atime;
+
 			// \x83\x8A\x83v\x83\x89\x83C\x82\xF0\x95Ԃ\xB7
 			goto reply;
 

Modified: trunk/ttssh2/ttxssh/ssh.h
===================================================================
--- trunk/ttssh2/ttxssh/ssh.h	2014-06-06 16:27:23 UTC (rev 5606)
+++ trunk/ttssh2/ttxssh/ssh.h	2014-06-07 04:56:18 UTC (rev 5607)
@@ -722,6 +722,8 @@
 	// for receiving file
 	long long filetotalsize;
 	long long filercvsize;
+	DWORD filemtime;
+	DWORD fileatime;
 } scp_t;
 
 enum sftp_state {



Ttssh2-commit メーリングリストの案内
Back to archive index