[Ttssh2-commit] [9091] TFileVarProto に stat() と utime() を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 12月 20日 (日) 21:13:34 JST


Revision: 9091
          https://osdn.net/projects/ttssh2/scm/svn/commits/9091
Author:   zmatsuo
Date:     2020-12-20 21:13:34 +0900 (Sun, 20 Dec 2020)
Log Message:
-----------
TFileVarProto に stat() と utime() を追加

- kermit.c の stat(),utime() を切り替え

Modified Paths:
--------------
    trunk/teraterm/teraterm/filesys_proto.h
    trunk/teraterm/ttpfile/filesys_win32.cpp
    trunk/teraterm/ttpfile/kermit.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/filesys_proto.h
===================================================================
--- trunk/teraterm/teraterm/filesys_proto.h	2020-12-20 12:13:25 UTC (rev 9090)
+++ trunk/teraterm/teraterm/filesys_proto.h	2020-12-20 12:13:34 UTC (rev 9091)
@@ -28,6 +28,8 @@
 
 #pragma once
 
+#include <sys/types.h>	// for struct utimbuf
+
 typedef struct FileVarProto {
 	// protosys_proto.cpp\x93\xE0\x82̂ݎg\x97p
 	WORD OpId;
@@ -71,16 +73,20 @@
 	void (*Destroy)(struct FileVarProto *fv);
 	void *data;
 
-	// file I/O
-	BOOL (*OpenRead)(struct FileVarProto *fv, const char *filenameU8);
-	BOOL (*OpenWrite)(struct FileVarProto *fv, const char *filenameU8);
+	// file I/O, Filename related functions
+	BOOL (*OpenRead)(struct FileVarProto *fv, const char *filename);
+	BOOL (*OpenWrite)(struct FileVarProto *fv, const char *filename);
 	size_t (*ReadFile)(struct FileVarProto *fv, void *buf, size_t bytes);
 	size_t (*WriteFile)(struct FileVarProto *fv, const void *buf, size_t bytes);
 	void (*Close)(struct FileVarProto *fv);
-	size_t (*GetFSize)(struct FileVarProto *fv, const char *filenameU8);
 	int (*Seek)(struct FileVarProto *fv, size_t offset);
 	void (*FileSysDestroy)(struct FileVarProto *fv);
 	HANDLE FileHandle;
+	//
+	size_t (*GetFSize)(struct FileVarProto *fv, const char *filename);
+	int (*utime)(const char *filename, struct _utimbuf* const _Time);
+	int (*stat)(const char *filename, struct _stati64* _Stat);
+	BOOL (*SetFilenameEncodeUTF8)(BOOL utf8);
 
 	// UI
 	void (*InitDlgProgress)(struct FileVarProto *fv, int *CurProgStat);

Modified: trunk/teraterm/ttpfile/filesys_win32.cpp
===================================================================
--- trunk/teraterm/ttpfile/filesys_win32.cpp	2020-12-20 12:13:25 UTC (rev 9090)
+++ trunk/teraterm/ttpfile/filesys_win32.cpp	2020-12-20 12:13:34 UTC (rev 9091)
@@ -27,6 +27,9 @@
  */
 
 #include <windows.h>
+#include <sys/stat.h>
+#include <sys/utime.h>
+
 #include "tttypes.h"
 #include "codeconv.h"
 
@@ -91,12 +94,12 @@
 
 /**
  *	\x83t\x83@\x83C\x83\x8B\x82̃t\x83@\x83C\x83\x8B\x83T\x83C\x83Y\x82\xF0\x8E擾
- *	@param[in]	filenameU8		\x83t\x83@\x83C\x83\x8B\x96\xBC(UTF-8)
+ *	@param[in]	filename		\x83t\x83@\x83C\x83\x8B\x96\xBC(UTF-8)
  *	@retval		\x83t\x83@\x83C\x83\x8B\x83T\x83C\x83Y
  */
-static size_t _GetFSize(struct FileVarProto *fv, const char *filenameU8)
+static size_t _GetFSize(struct FileVarProto *fv, const char *filename)
 {
-	size_t file_size = GetFSize64W(wc::fromUtf8(filenameU8));
+	size_t file_size = GetFSize64W(wc::fromUtf8(filename));
 	return file_size;
 }
 
@@ -104,7 +107,7 @@
  *	@retval	0	ok
  *	@retval	-1	error
  * TODO size_t \x88ȏ\xE3\x82̃t\x83@\x83C\x83\x8B\x82̈\xB5\x82\xA2
- * 
+ *
  */
 static int Seek(struct FileVarProto *fv, size_t offset)
 {
@@ -124,6 +127,16 @@
 	return 0;
 }
 
+static int _stat(const char *filename, struct _stati64* _Stat)
+{
+	return _stati64(filename, _Stat);
+}
+
+static int __utime(const char *filename, struct _utimbuf* const _Time)
+{
+	return _utime(filename, _Time);
+}
+
 static void FileSysDestroy(TFileVarProto *fv)
 {
 	fv->Close(fv);
@@ -137,7 +150,9 @@
 	fv->ReadFile = _ReadFile;
 	fv->WriteFile = _WriteFile;
 	fv->Close = _Close;
+	fv->Seek = Seek;
 	fv->GetFSize = _GetFSize;
-	fv->Seek = Seek;
+	fv->utime = _utime;
+	fv->stat = _stat;
 	fv->FileSysDestroy = FileSysDestroy;
 }

Modified: trunk/teraterm/ttpfile/kermit.c
===================================================================
--- trunk/teraterm/ttpfile/kermit.c	2020-12-20 12:13:25 UTC (rev 9090)
+++ trunk/teraterm/ttpfile/kermit.c	2020-12-20 12:13:34 UTC (rev 9091)
@@ -1051,7 +1051,7 @@
 		return TRUE;
 	}
 
-	if (_stati64(fv->FullName, &st) == 0) {
+	if (fv->stat(fv->FullName, &st) == 0) {
 		kv->FileAttrFlag = KMT_ATTR_TIME | KMT_ATTR_MODE | KMT_ATTR_SIZE | KMT_ATTR_TYPE;
 		kv->FileType = FALSE; // Binary
 		kv->FileTime = st.st_mtime;
@@ -1587,7 +1587,7 @@
 				memset(&utm, 0, sizeof(utm));
 				utm.actime  = kv->FileTime;
 				utm.modtime = kv->FileTime;
-				_utime(fv->FullName, &utm);
+				fv->utime(fv->FullName, &utm);
 			}
 		}
 	}


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