[Ttssh2-commit] [9012] GetNextFname() の仕様を変更

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 11月 2日 (月) 00:39:25 JST


Revision: 9012
          https://osdn.net/projects/ttssh2/scm/svn/commits/9012
Author:   zmatsuo
Date:     2020-11-02 00:39:25 +0900 (Mon, 02 Nov 2020)
Log Message:
-----------
GetNextFname() の仕様を変更

- ファイル名のポインタを返すようにした
  - 従来は TFileVarProto 内の FullName が更新
  - 更新できたとき TRUE が返る
- TFileVarProto 構造体のメンバ FullName を削除
- 各プロトコルファイルの構造体に FullName を追加

Modified Paths:
--------------
    branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp
    branches/proto_unicode/teraterm/teraterm/filesys_proto.h
    branches/proto_unicode/teraterm/ttpfile/bplus.c
    branches/proto_unicode/teraterm/ttpfile/filesys_io.h
    branches/proto_unicode/teraterm/ttpfile/filesys_win32.cpp
    branches/proto_unicode/teraterm/ttpfile/ftlib.c
    branches/proto_unicode/teraterm/ttpfile/ftlib.h
    branches/proto_unicode/teraterm/ttpfile/kermit.c
    branches/proto_unicode/teraterm/ttpfile/quickvan.c
    branches/proto_unicode/teraterm/ttpfile/xmodem.c
    branches/proto_unicode/teraterm/ttpfile/ymodem.c
    branches/proto_unicode/teraterm/ttpfile/zmodem.c

-------------- next part --------------
Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp
===================================================================
--- branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp	2020-11-01 15:39:25 UTC (rev 9012)
@@ -723,7 +723,6 @@
 	};
 	PFileVarProto fv;
 	char TempFull[MAX_PATH];
-	int i, j;
 	const char *UILanguageFile = ts.UILanguageFile;
 
 	switch (Message) {
@@ -740,10 +739,14 @@
 		case IDOK:
 			if (fv!=NULL) {
 				GetDlgItemText(Dialog, IDC_GETFN, TempFull, sizeof(TempFull));
-				if (strlen(TempFull)==0) return TRUE;
-				GetFileNamePos(TempFull,&i,&j);
-				FitFileName(&(TempFull[j]),sizeof(TempFull) - j, NULL);
-				strncat_s(fv->FullName,sizeof(fv->FullName),&(TempFull[j]),_TRUNCATE);
+				if (strlen(TempFull)==0) {
+					fv->FileNames = NULL;
+					return TRUE;
+				}
+				int FnPos;
+				GetFileNamePos(TempFull, NULL, &FnPos);
+				FitFileName(&(TempFull[FnPos]),sizeof(TempFull) - FnPos, NULL);
+				fv->FileNames = MakeStrArrayFromStr(&(TempFull[FnPos]));
 			}
 			EndDialog(Dialog, 1);
 			return TRUE;
@@ -995,13 +998,13 @@
 	strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE);
 
 	if (filename == NULL) {
-		if (! _GetGetFname(FileVar->HMainWin,FileVar, &ts) || (strlen(FileVar->FullName)==0)) {
+		if (! _GetGetFname(FileVar->HMainWin,FileVar, &ts) || FileVar->FileNames == NULL) {
 			FreeFileVar_(&FileVar);
 			return FALSE;
 		}
 	}
 	else {
-		strncpy_s(FileVar->FullName, sizeof(FileVar->FullName),filename, _TRUNCATE);
+		FileVar->FileNames = MakeStrArrayFromStr(filename);
 		FileVar->NoMsg = TRUE;
 	}
 	KermitStart(IdKmtGet);
@@ -1065,21 +1068,6 @@
 	return TRUE;
 }
 
-static void XMODEMStart(int mode)
-{
-	if (! ProtoStart())
-		return;
-
-	TalkStatus = IdTalkQuiet;
-
-	/* disable transmit delay (serial port) */
-	cv.DelayFlag = FALSE;
-
-	if (! OpenProtoDlg(FileVar,PROTO_XM,mode, ts.XmodemOpt,ts.XmodemBin)) {
-		ProtoEnd();
-	}
-}
-
 /**
  *	XMODEM\x8E\xF3\x90M
  *
@@ -1152,9 +1140,22 @@
 		ts.XmodemBin = ParamBinaryFlag;
 		FileVar->NoMsg = TRUE;
 	}
-	XMODEMStart(IdXReceive);
-	fv->SetDlgProtoFileName(fv, fv->FullName);
 
+	if (! ProtoStart()) {
+		return FALSE;
+	}
+
+	TalkStatus = IdTalkQuiet;
+
+	/* disable transmit delay (serial port) */
+	cv.DelayFlag = FALSE;
+
+	int mode = IdXReceive;
+	if (! OpenProtoDlg(FileVar,PROTO_XM,mode, ts.XmodemOpt,ts.XmodemBin)) {
+		ProtoEnd();
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
@@ -1226,9 +1227,22 @@
 		}
 		FileVar->NoMsg = TRUE;
 	}
-	XMODEMStart(IdXSend);
-	fv->SetDlgProtoFileName(fv, fv->FullName);
 
+	if (! ProtoStart()) {
+		return FALSE;
+	}
+
+	TalkStatus = IdTalkQuiet;
+
+	/* disable transmit delay (serial port) */
+	cv.DelayFlag = FALSE;
+
+	int mode = IdXSend;
+	if (! OpenProtoDlg(FileVar,PROTO_XM,mode, ts.XmodemOpt,ts.XmodemBin)) {
+		ProtoEnd();
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
@@ -1507,7 +1521,6 @@
 		return FALSE;
 
 	if (filename == NULL) {
-		FileVar->FullName[0] = 0;
 		char **filenames = _GetTransFname(fv->HMainWin, FileVar->DlgCaption);
 		if (filenames == NULL) {
 			ProtoEnd();

Modified: branches/proto_unicode/teraterm/teraterm/filesys_proto.h
===================================================================
--- branches/proto_unicode/teraterm/teraterm/filesys_proto.h	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/teraterm/filesys_proto.h	2020-11-01 15:39:25 UTC (rev 9012)
@@ -38,9 +38,6 @@
 	HWND HWin;
 	char DlgCaption[40];
 
-	// \x91\x97\x8E\xF3\x90M\x8E\x9E\x83\x8F\x81[\x83N
-	char FullName[MAX_PATH];	// read/write\x82\xB7\x82\xE9\x83t\x83@\x83C\x83\x8B\x96\xBC(\x8Ae\x83v\x83\x8D\x83g\x83R\x83\x8B\x93\xE0\x82ŏ\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xB7\x82邱\x82Ƃ\xA0\x82\xE8)
-
 	// \x91\x97\x90M\x83t\x83@\x83C\x83\x8B\x96\xBC\x94z\x97\xF1
 	//	\x83t\x83\x8B\x83p\x83X\x82̃t\x83@\x83C\x83\x8B\x96\xBC\x94z\x97\xF1(\x88\xEA\x94ԍŌ\xE3\x82\xCDNULL)
 	char **FileNames;

Modified: branches/proto_unicode/teraterm/ttpfile/bplus.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/bplus.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/bplus.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -75,6 +75,7 @@
   BOOL CtlEsc;
   BYTE Q[8];
 	TProtoLog *log;
+	const char *FullName;		// Windows\x8F\xE3\x82̃t\x83@\x83C\x83\x8B\x96\xBC UTF-8
 } TBPVar;
 typedef TBPVar far *PBPVar;
 
@@ -103,15 +104,16 @@
 {
   BOOL r;
   TFileIO *fileio = fv->file;
+  PBPVar bv = fv->data;
 
   if (fv->FileOpen) return TRUE;
-  if (fv->FullName[0]==0) return FALSE;
+  if (bv->FullName == NULL) return FALSE;
 
-  r = fileio->OpenRead(fileio, fv->FullName);
+  r = fileio->OpenRead(fileio, bv->FullName);
   fv->FileOpen = r;
   if (r == TRUE) {
-    fv->SetDlgProtoFileName(fv, fv->FullName);
-    fv->FileSize = fileio->GetFSize(fileio, fv->FullName);
+    fv->SetDlgProtoFileName(fv, bv->FullName);
+    fv->FileSize = fileio->GetFSize(fileio, bv->FullName);
   }
   return fv->FileOpen;
 }
@@ -575,9 +577,10 @@
 static BOOL FTCreateFile(PFileVarProto fv)
 {
 	TFileIO *file = fv->file;
+	PBPVar bv = fv->data;
 
-	fv->SetDlgProtoFileName(fv, fv->FullName);
-	fv->FileOpen = file->OpenWrite(file, fv->FullName);
+	fv->SetDlgProtoFileName(fv, bv->FullName);
+	fv->FileOpen = file->OpenWrite(file, bv->FullName);
 	if (! fv->FileOpen) {
 		if (fv->NoMsg) {
 			MessageBox(fv->HMainWin,"Cannot create file",
@@ -603,7 +606,6 @@
 //  char Temp[HostNameMaxLength + 1]; // 81(yutaka)
   char Temp[81]; // 81(yutaka)
   TFileIO *fileio = fv->file;
-  char *filename;
 
   switch (bv->PktIn[2]) {
     case 'C': /* Close */
@@ -639,10 +641,10 @@
       }
       Temp[j] = 0;
 
-      filename = fileio->GetRecieveFilename(fileio, fv->RecievePath, FALSE, Temp, !fv->OverWrite);
-      strncpy_s(fv->FullName, _countof(fv->FullName), filename, _TRUNCATE);
-      free(filename);
+      free((void *)bv->FullName);
+      bv->FullName = fileio->GetRecieveFilename(fileio, fv->RecievePath, FALSE, Temp, !fv->OverWrite);
 
+
       /* file open */
       if (! FTCreateFile(fv))
       {
@@ -687,15 +689,17 @@
 	}
 	Temp[j] = 0;
 
-	filename = fileio->GetRecieveFilename(fileio, Temp, FALSE, fv->RecievePath, !fv->OverWrite);
-	strncpy_s(fv->FullName, _countof(fv->FullName), filename, _TRUNCATE);
-	free(filename);
+	free((void *)bv->FullName);
+	bv->FullName = fileio->GetRecieveFilename(fileio, Temp, FALSE, fv->RecievePath, !fv->OverWrite);
 
 	/* file open */
 	if (! BPOpenFileToBeSent(fv))
 	{
+	  PBPVar bv = fv->data;
+
 	  /* if file not found, ask user new file name */
-	  fv->FullName[0] = 0;
+	  free((void *)bv->FullName);
+	  bv->FullName = NULL;
 
 	  // \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8AJ\x82\xA2\x82ăt\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x83\x86\x81[\x83U\x81[\x82Ɏw\x92肵\x82Ă\xE0\x82炤
 	  // \x82\xB1\x82̈ʒu\x82ōs\x82\xA4\x82͓̂K\x90؂łȂ\xA2\x82Ǝv\x82\xED\x82\xEA\x82邽\x82\xDF
@@ -1015,6 +1019,8 @@
 		log->Destory(log);
 		bv->log = NULL;
 	}
+	free((void *)bv->FullName);
+	bv->FullName = NULL;
 	free(bv);
 	fv->data = NULL;
 }

Modified: branches/proto_unicode/teraterm/ttpfile/filesys_io.h
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/filesys_io.h	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/filesys_io.h	2020-11-01 15:39:25 UTC (rev 9012)
@@ -45,6 +45,7 @@
 	//
 	size_t (*GetFSize)(struct FileIO *fv, const char *filename);
 	int (*utime)(struct FileIO *fv, const char *filename, struct _utimbuf* const _Time);
+	BOOL (*SetFMtime)(struct FileIO *fv, const char *FName, DWORD mtime);
 	int (*stat)(struct FileIO *fv, const char *filename, struct _stati64* _Stat);
 	char *(*GetSendFilename)(struct FileIO *fv, const char *fullname, BOOL utf8, BOOL space, BOOL upper);
 	char *(*GetRecieveFilename)(struct FileIO *fv, const char* filename, BOOL utf8, const char *path, BOOL unique);

Modified: branches/proto_unicode/teraterm/ttpfile/filesys_win32.cpp
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/filesys_win32.cpp	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/filesys_win32.cpp	2020-11-01 15:39:25 UTC (rev 9012)
@@ -363,6 +363,15 @@
 	return (long)st.st_mtime;
 }
 
+static BOOL _SetFMtime(TFileIO *fv, const char *FName, DWORD mtime)
+{
+	struct _utimbuf filetime;
+
+	filetime.actime = mtime;
+	filetime.modtime = mtime;
+	return _utime(FName, &filetime);
+}
+
 static void FileSysDestroy(TFileIO *fv)
 {
 	TFileIOWin32 *data = (TFileIOWin32 *)fv->data;
@@ -399,5 +408,6 @@
 	fv->GetSendFilename = GetSendFilename;
 	fv->GetRecieveFilename = GetRecieveFilename;
 	fv->GetFMtime = GetFMtime;
+	fv->SetFMtime = _SetFMtime;
 	return fv;
 }

Modified: branches/proto_unicode/teraterm/ttpfile/ftlib.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/ftlib.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/ftlib.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -39,16 +39,23 @@
 #include "ftlib.h"
 #include "tt_res.h"
 
-BOOL GetNextFname(PFileVarProto fv)
+/**
+ *	\x83t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x8E擾
+ *
+ *	@return		\x83t\x83@\x83C\x83\x8B\x96\xBC
+ *				NULL\x82̂Ƃ\xAB\x8E\x9F\x82̃t\x83@\x83C\x83\x8B\x82͂Ȃ\xA2
+ *				\x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7 free() \x82\xB7\x82邱\x82\xC6
+ */
+char *GetNextFname(PFileVarProto fv)
 {
-	const char *f = fv->FileNames[fv->FNCount];
+	char *f = fv->FileNames[fv->FNCount];
 	if (f == NULL) {
-		return FALSE; /* no more file name */
+		/* no more file name */
+		return NULL;
 	}
 	fv->FNCount++;
-
-	strncpy_s(fv->FullName, sizeof(fv->FullName), f, _TRUNCATE);
-	return TRUE;
+	f = _strdup(f);
+	return f;
 }
 
 WORD UpdateCRC(BYTE b, WORD CRC)

Modified: branches/proto_unicode/teraterm/ttpfile/ftlib.h
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/ftlib.h	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/ftlib.h	2020-11-01 15:39:25 UTC (rev 9012)
@@ -36,7 +36,7 @@
 #endif
 
 void GetLongFName(PCHAR FullName, PCHAR LongName, int destlen);
-BOOL GetNextFname(PFileVarProto fv);
+char *GetNextFname(PFileVarProto fv);
 WORD UpdateCRC(BYTE b, WORD CRC);
 LONG UpdateCRC32(BYTE b, LONG CRC);
 

Modified: branches/proto_unicode/teraterm/ttpfile/kermit.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/kermit.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/kermit.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -77,6 +77,7 @@
   int FileMode;
   LONGLONG FileSize;
 	TProtoLog *log;
+	const char *FullName;		// Windows\x8F\xE3\x82̃t\x83@\x83C\x83\x8B\x96\xBC UTF-8
 } TKmtVar;
 typedef TKmtVar far *PKmtVar;
 
@@ -1050,13 +1051,16 @@
 	BOOL r;
 	char *filename;
 
-	if (! GetNextFname(fv))
+	filename = GetNextFname(fv);
+	if (filename == NULL)
 	{
 		KmtSendEOTPacket(fv,kv,cv);
 		return TRUE;
 	}
+	free((void *)kv->FullName);
+	kv->FullName = filename;
 
-	if (file->stat(file, fv->FullName, &st) == 0) {
+	if (file->stat(file, kv->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;
@@ -1067,7 +1071,7 @@
 	}
 
 	/* file open */
-	r = file->OpenRead(file, fv->FullName);
+	r = file->OpenRead(file, kv->FullName);
 	fv->FileOpen = r;
 	if (! fv->FileOpen)
 	{
@@ -1081,13 +1085,13 @@
 		return FALSE;
 	}
 	else
-		fv->FileSize = file->GetFSize(file, fv->FullName);
+		fv->FileSize = file->GetFSize(file, kv->FullName);
 
 	fv->ByteCount = 0;
 	fv->ProgStat = 0;
 	fv->StartTime = GetTickCount();
 
-	fv->SetDlgProtoFileName(fv, fv->FullName);
+	fv->SetDlgProtoFileName(fv, kv->FullName);
 	SetDlgNum(fv->HWin, IDC_PROTOBYTECOUNT, fv->ByteCount);
 	SetDlgPercent(fv->HWin, IDC_PROTOPERCENT, IDC_PROTOPROGRESS,
 		fv->ByteCount, fv->FileSize, &fv->ProgStat);
@@ -1157,7 +1161,7 @@
 	kv->PktNum = 0;
 	kv->PktNumOffset = 0;
 
-	filename = file->GetRecieveFilename(file, fv->FullName, FALSE, NULL, FALSE);
+	filename = file->GetRecieveFilename(file, kv->FullName, FALSE, NULL, FALSE);
 	if (strlen(filename) >= filename_len_max) {
 		filename[filename_len_max] = 0;
 	}
@@ -1317,10 +1321,11 @@
 
 static BOOL FTCreateFile(PFileVarProto fv)
 {
+	PKmtVar kv = fv->data;
 	TFileIO *file = fv->file;
 
-	fv->SetDlgProtoFileName(fv, fv->FullName);
-	fv->FileOpen = file->OpenWrite(file, fv->FullName);
+	fv->SetDlgProtoFileName(fv, kv->FullName);
+	fv->FileOpen = file->OpenWrite(file, kv->FullName);
 	if (! fv->FileOpen) {
 		if (fv->NoMsg) {
 			MessageBox(fv->HMainWin,"Cannot create file",
@@ -1460,15 +1465,15 @@
 			(kv->KmtState==GetInit))
 		{
 			TFileIO *file = fv->file;
-			char *filename;
 			kv->KmtMode = IdKmtReceive;
 
+			free((void *)kv->FullName);
+			kv->FullName = NULL;
+
 			Len = sizeof(FNBuff);
 			KmtDecode(fv,kv,FNBuff,&Len);
 			FNBuff[Len] = 0;
-			filename = file->GetRecieveFilename(file, FNBuff, FALSE, fv->RecievePath, !fv->OverWrite);
-			strncpy_s(fv->FullName, _countof(fv->FullName), filename, _TRUNCATE);
-			free(filename);
+			kv->FullName = file->GetRecieveFilename(file, FNBuff, FALSE, fv->RecievePath, !fv->OverWrite);
 			/* file open */
 			if (! FTCreateFile(fv)) return FALSE;
 			kv->KmtState = ReceiveData;
@@ -1622,7 +1627,7 @@
 				memset(&utm, 0, sizeof(utm));
 				utm.actime  = kv->FileTime;
 				utm.modtime = kv->FileTime;
-				file->utime(file, fv->FullName, &utm);
+				file->utime(file, kv->FullName, &utm);
 			}
 		}
 	}
@@ -1671,6 +1676,8 @@
 		log->Destory(log);
 		kv->log = NULL;
 	}
+	free((void *)kv->FullName);
+	kv->FullName = NULL;
 	free(kv);
 	fv->data = NULL;
 }

Modified: branches/proto_unicode/teraterm/ttpfile/quickvan.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/quickvan.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/quickvan.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -62,6 +62,7 @@
   BOOL EnqFlag;
   BYTE CheckSum;
 	TProtoLog *log;
+	const char *FullName;	// Windows\x8F\xE3\x82̃t\x83@\x83C\x83\x8B\x96\xBC UTF-8
 } TQVVar;
 typedef TQVVar far *PQVVar;
 
@@ -419,9 +420,10 @@
 static BOOL FTCreateFile(PFileVarProto fv)
 {
 	TFileIO *file = fv->file;
+	PQVVar qv = fv->data;
 
-	fv->SetDlgProtoFileName(fv, fv->FullName);
-	fv->FileOpen = file->OpenWrite(file, fv->FullName);
+	fv->SetDlgProtoFileName(fv, qv->FullName);
+	fv->FileOpen = file->OpenWrite(file, qv->FullName);
 	if (! fv->FileOpen) {
 		if (fv->NoMsg) {
 			MessageBox(fv->HMainWin,"Cannot create file",
@@ -446,7 +448,6 @@
   int i;
   WORD w;
   BYTE b;
-  char *filename;
 
   if ((qv->QVState != QV_RecvInit2) &&
       (qv->QVState != QV_RecvNext))
@@ -453,9 +454,8 @@
     return TRUE;
 
   /* file name */
-  filename = file->GetRecieveFilename(file, &(qv->PktIn[5]), FALSE, fv->RecievePath, !fv->OverWrite);
-  strncpy_s(fv->FullName, _countof(fv->FullName), filename, _TRUNCATE);
-  free(filename);
+  free((void *)qv->FullName);
+  qv->FullName = file->GetRecieveFilename(file, &(qv->PktIn[5]), FALSE, fv->RecievePath, !fv->OverWrite);
   /* file open */
   if (! FTCreateFile(fv)) return FALSE;
   /* file size */
@@ -537,7 +537,7 @@
 	  time.tm_isdst = 0;
 	  timebuf.actime = mktime(&time);
 	  timebuf.modtime = timebuf.actime;
-	  utime(fv->FullName,&timebuf);
+	  utime(qv->FullName,&timebuf);
 	}
       }
       QVSendVSTAT(fv,qv);
@@ -858,14 +858,17 @@
   TFileIO *file = fv->file;
   char *filename;
 
-  if (! GetNextFname(fv))
+  filename = GetNextFname(fv);
+  if (filename == NULL)
   {
     QVSendEOT(fv,qv,cv);
     return;
   }
+  free((void *)qv->FullName);
+  qv->FullName = filename;
 
   /* find file and get file info */
-  fv->FileSize = file->GetFSize(file, fv->FullName);
+  fv->FileSize = file->GetFSize(file, qv->FullName);
   if (fv->FileSize>0)
   {
     qv->FileEnd = (WORD)(fv->FileSize >> 7);
@@ -878,7 +881,7 @@
   }
 
   /* file open */
-  r = file->OpenRead(file, fv->FullName);
+  r = file->OpenRead(file, qv->FullName);
   fv->FileOpen = r;
   if (! fv->FileOpen)
   {
@@ -905,7 +908,7 @@
   qv->PktOut[i] = 0;
   i++;
   /* date */
-  stat(fv->FullName,&stbuf);
+  stat(qv->FullName,&stbuf);
   localtime_s(&tmbuf, &stbuf.st_mtime);
 
   QVPutNum2(qv,(WORD)((tmbuf.tm_year+1900) / 100),&i);
@@ -1348,6 +1351,8 @@
 		log->Destory(log);
 		qv->log = NULL;
 	}
+	free((void *)qv->FullName);
+	qv->FullName = NULL;
 	free(qv);
 	fv->data = NULL;
 }

Modified: branches/proto_unicode/teraterm/ttpfile/xmodem.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/xmodem.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/xmodem.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -57,6 +57,7 @@
   int TOutVLong;
   int CANCount;
 	TProtoLog *log;
+	const char *FullName;		// Windows\x8F\xE3\x82̃t\x83@\x83C\x83\x8B\x96\xBC UTF-8
 } TXVar;
 typedef TXVar far *PXVar;
 
@@ -227,22 +228,23 @@
 		log->LogState = 0;
 	}
 
-	GetNextFname(fv);
-	fv->FileSize = 0;
+	xv->FullName = GetNextFname(fv);
 	if (xv->XMode == IdXSend) {
-		fv->FileOpen = file->OpenRead(file, fv->FullName);
+		fv->FileOpen = file->OpenRead(file, xv->FullName);
 		if (fv->FileOpen == FALSE) {
 			return FALSE;
 		}
-		fv->FileSize = file->GetFSize(file, fv->FullName);
+		fv->FileSize = file->GetFSize(file, xv->FullName);
 		fv->InitDlgProgress(fv, &fv->ProgStat);
 	} else {
-		fv->FileOpen = file->OpenWrite(file, fv->FullName);
+		fv->FileOpen = file->OpenWrite(file, xv->FullName);
 		if (fv->FileOpen == FALSE) {
 			return FALSE;
 		}
+		fv->FileSize = 0;
 		fv->ProgStat = -1;
 	}
+	fv->SetDlgProtoFileName(fv, xv->FullName);
 	fv->StartTime = GetTickCount();
 
 	xv->PktNumOffset = 0;
@@ -664,6 +666,8 @@
 		log->Destory(log);
 		xv->log = NULL;
 	}
+	free((void*)xv->FullName);
+	xv->FullName = NULL;
 	free(xv);
 	fv->data = NULL;
 }

Modified: branches/proto_unicode/teraterm/ttpfile/ymodem.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/ymodem.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/ymodem.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -69,6 +69,7 @@
   BYTE LastMessage;
   BOOL RecvFilesize;
 	TProtoLog *log;
+	const char *FullName;		// Windows\x8F\xE3\x82̃t\x83@\x83C\x83\x8B\x96\xBC UTF-8
 } TYVar;
 typedef TYVar *PYVar;
 
@@ -299,11 +300,11 @@
 			file->Close(file);
 
 			if (fv->FileMtime > 0) {
-				SetFMtime(fv->FullName, fv->FileMtime);
+				file->SetFMtime(file, yv->FullName, fv->FileMtime);
 			}
 		}
-		fv->FileOpen = file->OpenRead(file, fv->FullName);
-		fv->FileSize = file->GetFSize(file, fv->FullName);
+		fv->FileOpen = file->OpenRead(file, yv->FullName);
+		fv->FileSize = file->GetFSize(file, yv->FullName);
 	} else {
 		fv->FileOpen = FALSE;
 		fv->FileSize = 0;
@@ -317,7 +318,7 @@
 		fv->ProgStat = -1;
 	}
 	fv->StartTime = GetTickCount();
-	fv->SetDlgProtoFileName(fv, fv->FullName);
+	fv->SetDlgProtoFileName(fv, yv->FullName);
 
 	yv->PktNumOffset = 0;
 	yv->PktNum = 0;
@@ -336,9 +337,11 @@
 	PYVar yv = fv->data;
 
 	if (yv->YMode == IdYSend) {
-		if (!GetNextFname(fv)) {
+		char *filename = GetNextFname(fv);
+		if (filename == NULL) {
 			return FALSE;
 		}
+		yv->FullName = filename;
 	}
 
 	if ((ts->LogFlag & LOG_Y)!=0) {
@@ -449,9 +452,10 @@
 static BOOL FTCreateFile(PFileVarProto fv)
 {
 	TFileIO *file = fv->file;
+	PYVar yv = fv->data;
 
-	fv->SetDlgProtoFileName(fv, fv->FullName);
-	fv->FileOpen = file->OpenWrite(file, fv->FullName);
+	fv->SetDlgProtoFileName(fv, yv->FullName);
+	fv->FileOpen = file->OpenWrite(file, yv->FullName);
 	if (! fv->FileOpen) {
 		if (fv->NoMsg) {
 			MessageBox(fv->HMainWin,"Cannot create file",
@@ -517,7 +521,7 @@
 					fv->FileOpen = FALSE;
 
 					if (fv->FileMtime > 0) {
-						SetFMtime(fv->FullName, fv->FileMtime);
+						file->SetFMtime(file, yv->FullName, fv->FileMtime);
 					}
 
 					// 1\x89\xF1\x96ڂ\xCCEOT\x82ɑ΂\xB5\x82\xC4NAK\x82\xF0\x95Ԃ\xB7
@@ -642,7 +646,6 @@
 		int ret;
 		BYTE *p;
 		char *name, *nameend;
-		char *filename;
 
 		p = (BYTE *)malloc(yv->__DataLen + 1);
 		memset(p, 0, yv->__DataLen + 1);
@@ -649,9 +652,8 @@
 		memcpy(p, &(yv->PktIn[3]), yv->__DataLen);
 		name = p;
 
-		filename = file->GetRecieveFilename(file, name, FALSE, fv->RecievePath, !fv->OverWrite);
-		strncpy_s(fv->FullName, _countof(fv->FullName), filename, _TRUNCATE);
-		free(filename);
+		free((void *)yv->FullName);
+		yv->FullName = file->GetRecieveFilename(file, name, FALSE, fv->RecievePath, !fv->OverWrite);
 		if (!FTCreateFile(fv)) {
 			free(p);
 			return FALSE;
@@ -739,11 +741,13 @@
 				// If we already send EOT, ACK means that client confirms it.
 				if (yv->SendEot)
 				{
+					char *filename;
 					// Reset the flag.
 					yv->SendEot = 0;
 
 					// \x91\x97\x90M\x83t\x83@\x83C\x83\x8B\x82\xAA\x8Ec\x82\xC1\x82Ă\xA2\x82Ȃ\xA2\x8Fꍇ\x82́A\x81u\x91S\x82Ẵt\x83@\x83C\x83\x8B\x82\xF0\x93]\x91\x97\x8FI\x97\xB9\x81v\x82\xF0\x92ʒm\x82\xB7\x82\xE9\x81B
-					if (!GetNextFname(fv))
+					filename = GetNextFname(fv);
+					if (filename == NULL)
 					{
 						// If it is the last file.
 						yv->LastSendEot = 1;
@@ -752,6 +756,8 @@
 					else
 					{
 						// Process with next file.
+						free((void *)yv->FullName);
+						yv->FullName = filename;
 						initialize_file_info(fv, yv);
 					}
 				}
@@ -941,7 +947,7 @@
 				yv->PktOut[0] = SOH;
 
 				// Timestamp.
-				fv->FileMtime = file->GetFMtime(file, fv->FullName);
+				fv->FileMtime = file->GetFMtime(file, yv->FullName);
 
 				filename = file->GetSendFilename(file, yv->FullName, FALSE, FALSE, FALSE);
 				ret = _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s", filename);
@@ -1156,6 +1162,8 @@
 		log->Destory(log);
 		yv->log = NULL;
 	}
+	free((void *)yv->FullName);
+	yv->FullName = NULL;
 	free(yv);
 	fv->data = NULL;
 }

Modified: branches/proto_unicode/teraterm/ttpfile/zmodem.c
===================================================================
--- branches/proto_unicode/teraterm/ttpfile/zmodem.c	2020-11-01 15:39:08 UTC (rev 9011)
+++ branches/proto_unicode/teraterm/ttpfile/zmodem.c	2020-11-01 15:39:25 UTC (rev 9012)
@@ -80,6 +80,7 @@
   int TOutInit;
   int TOutFin;
 	TProtoLog *log;
+	const char *FullName;		// Windows\x8F\xE3\x82̃t\x83@\x83C\x83\x8B\x96\xBC UTF-8
 } TZVar;
 typedef TZVar far *PZVar;
 
@@ -567,7 +568,7 @@
 		ZSendCancel(zv);
 		return;
 	}
-	SetDlgItemText(fv->HWin, IDC_PROTOFNAME, fv->FullName);
+	SetDlgItemText(fv->HWin, IDC_PROTOFNAME, zv->FullName);
 
 	/* file name */
 	filename = file->GetSendFilename(file, zv->FullName, FALSE, TRUE, FALSE);
@@ -579,10 +580,10 @@
 	ZPutBin(zv, &(zv->PktOutCount), 0);
 	zv->CRC = UpdateCRC(0, zv->CRC);
 	/* file size */
-	fv->FileSize = file->GetFSize(file, fv->FullName);
+	fv->FileSize = file->GetFSize(file, zv->FullName);
 
 	/* timestamp */
-	fv->FileMtime = GetFMtime(fv->FullName);
+	fv->FileMtime = file->GetFMtime(file, zv->FullName);
 
 	// \x83t\x83@\x83C\x83\x8B\x82̃^\x83C\x83\x80\x83X\x83^\x83\x93\x83v\x82ƃp\x81[\x83~\x83b\x83V\x83\x87\x83\x93\x82\xE0\x91\x97\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B(2007.12.20 maya, yutaka)
 	_snprintf_s(&(zv->PktOut[zv->PktOutCount]),
@@ -850,6 +851,7 @@
 {
 	int Max;
 	TFileIO *file = fv->file;
+	char *filename;
 
 	if ((zv->ZState != Z_SendInit) && (zv->ZState != Z_SendEOF))
 		return;
@@ -860,18 +862,21 @@
 		fv->FileOpen = FALSE;
 
 		if (fv->FileMtime > 0) {
-			SetFMtime(fv->FullName, fv->FileMtime);
+			file->SetFMtime(file, zv->FullName, fv->FileMtime);
 		}
 	}
 
-	if (!GetNextFname(fv)) {
+	filename = GetNextFname(fv);
+	if (filename == NULL) {
 		zv->ZState = Z_SendFIN;
 		ZSendFIN(zv);
 		return;
 	}
+	free((void *)zv->FullName);
+	zv->FullName = filename;
 
 	/* file open */
-	fv->FileOpen = file->OpenRead(file, fv->FullName);
+	fv->FileOpen = file->OpenRead(file, zv->FullName);
 
 	if (zv->CtlEsc) {
 		if ((zv->RxHdr[ZF0] & ESCCTL) == 0) {
@@ -1023,7 +1028,7 @@
 				fv->FileOpen = FALSE;
 
 				if (fv->FileMtime > 0) {
-					SetFMtime(fv->FullName, fv->FileMtime);
+					file->SetFMtime(file, zv->FullName, fv->FileMtime);
 				}
 			}
 			zv->ZState = Z_RecvInit;
@@ -1041,9 +1046,10 @@
 static BOOL FTCreateFile(PFileVarProto fv)
 {
 	TFileIO *file = fv->file;
+	PZVar zv = fv->data;
 
-	fv->SetDlgProtoFileName(fv, fv->FullName);
-	fv->FileOpen = file->OpenWrite(file, fv->FullName);
+	fv->SetDlgProtoFileName(fv, zv->FullName);
+	fv->FileOpen = file->OpenWrite(file, zv->FullName);
 	if (! fv->FileOpen) {
 		if (fv->NoMsg) {
 			MessageBox(fv->HMainWin,"Cannot create file",
@@ -1071,7 +1077,6 @@
 	int mode;
 	int ret;
 	TFileIO* file = fv->file;
-	char *filename;
 
 	if ((zv->ZState != Z_RecvInit) && (zv->ZState != Z_RecvInit2))
 		return FALSE;
@@ -1082,9 +1087,8 @@
 	/* file name */
 	zv->PktIn[zv->PktInPtr] = 0;	/* for safety */
 
-	filename = file->GetRecieveFilename(file, zv->PktIn, FALSE, fv->RecievePath, !fv->OverWrite);
-	strncpy_s(fv->FullName, _countof(fv->FullName), filename, _TRUNCATE);
-	free(filename);
+	free((void *)zv->FullName);
+	zv->FullName = file->GetRecieveFilename(file, zv->PktIn, FALSE, fv->RecievePath, !fv->OverWrite);
 	/* file open */
 	if (!FTCreateFile(fv))
 		return FALSE;
@@ -1515,6 +1519,8 @@
 		log->Destory(log);
 		zv->log = NULL;
 	}
+	free((void *)zv->FullName);
+	zv->FullName = NULL;
 	free(zv);
 	fv->data = NULL;
 }


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