[Ttssh2-commit] [5273] ログファイルの扱いを 32bit API に変更

svnno****@sourc***** svnno****@sourc*****
2013年 5月 21日 (火) 12:15:40 JST


Revision: 5273
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5273
Author:   maya
Date:     2013-05-21 12:15:39 +0900 (Tue, 21 May 2013)
Log Message:
-----------
ログファイルの扱いを 32bit API に変更

Modified Paths:
--------------
    trunk/teraterm/teraterm/filesys.cpp
    trunk/teraterm/teraterm/ttdde.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/filesys.cpp
===================================================================
--- trunk/teraterm/teraterm/filesys.cpp	2013-05-20 13:39:50 UTC (rev 5272)
+++ trunk/teraterm/teraterm/filesys.cpp	2013-05-21 03:15:39 UTC (rev 5273)
@@ -385,7 +385,11 @@
 		CloseHandle(ptr->LogThread);
 		ptr->LogThread = (HANDLE)-1;
 	}
+#ifdef FileVarWin16
 	_lclose(ptr->FileHandle);
+#else
+	CloseHandle((HANDLE)ptr->FileHandle);
+#endif
 }
 
 // \x92x\x89\x84\x8F\x91\x82\xAB\x8D\x9E\x82ݗp\x83X\x83\x8C\x83b\x83h
@@ -395,6 +399,7 @@
 	PFileVar fv = (PFileVar)arg;
 	PCHAR buf;
 	DWORD buflen;
+	DWORD wrote;
 
 	PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
 
@@ -403,7 +408,11 @@
 			case WM_DPC_LOGTHREAD_SEND:
 				buf = (PCHAR)msg.wParam;
 				buflen = (DWORD)msg.lParam;
+#ifdef FileVarWin16
 				_lwrite(fv->FileHandle, buf, buflen );
+#else
+				WriteFile((HANDLE)LogVar->FileHandle, buf, buflen, &wrote, NULL);
+#endif
 				free(buf);   // \x82\xB1\x82\xB1\x82Ń\x81\x83\x82\x83\x8A\x89\xF0\x95\xFA
 				break;
 
@@ -558,7 +567,11 @@
 		LogVar->FileHandle = (int)CreateFile(LogVar->FullName, GENERIC_WRITE, dwShareMode, NULL,
 		                                     OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 		if (LogVar->FileHandle>0){
+#ifdef FileVarWin16
 			_llseek(LogVar->FileHandle,0,2);
+#else
+			SetFilePointer((HANDLE)LogVar->FileHandle, 0, NULL, FILE_END);
+#endif
 			/* 2007.05.24 Gentaro
 				If log file already exists,
 				a newline is inserted before the first timestamp.
@@ -800,6 +813,7 @@
 	PCHAR WriteBuf;
 	DWORD WriteBufMax, WriteBufLen;
 	CHAR tmp[128];
+	DWORD wrote;
 
 	if (! LogVar->FileOpen) return;
 	if (FileLog)
@@ -895,11 +909,21 @@
 	#endif
 					/* 2007.05.24 Gentaro */
 					if( eLineEnd == Line_FileHead ){
+#ifdef FileVarWin16
 						_lwrite(LogVar->FileHandle,"\r\n",2);
+#else
+						WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL);
+#endif
 					}
+#ifdef FileVarWin16
 					_lwrite(LogVar->FileHandle,"[",1);
 					_lwrite(LogVar->FileHandle, strtime, strlen(strtime));
 					_lwrite(LogVar->FileHandle,"] ",2);
+#else
+					WriteFile((HANDLE)LogVar->FileHandle, "[", 1, &wrote, NULL);
+					WriteFile((HANDLE)LogVar->FileHandle, strtime, strlen(strtime), &wrote, NULL);
+					WriteFile((HANDLE)LogVar->FileHandle, "] ", 2, &wrote, NULL);
+#endif
 				}
 				
 				/* 2007.05.24 Gentaro */
@@ -910,7 +934,11 @@
 					eLineEnd = Line_Other; /* clear endmark*/
 				}
 
+#ifdef FileVarWin16
 				_lwrite(LogVar->FileHandle,(PCHAR)&b,1);
+#else
+				WriteFile((HANDLE)LogVar->FileHandle, (PCHAR)&b, 1, &wrote, NULL);
+#endif
 				(LogVar->ByteCount)++;
 			}
 		}

Modified: trunk/teraterm/teraterm/ttdde.c
===================================================================
--- trunk/teraterm/teraterm/ttdde.c	2013-05-20 13:39:50 UTC (rev 5272)
+++ trunk/teraterm/teraterm/ttdde.c	2013-05-21 03:15:39 UTC (rev 5273)
@@ -593,8 +593,13 @@
 	case CmdLogWrite:
 		if (LogVar != NULL)
 		{
+			DWORD wrote;
+#ifdef FileVarWin16
 			_lwrite(LogVar->FileHandle,
 				ParamFileName,strlen(ParamFileName));
+#else
+			WriteFile((HANDLE)LogVar->FileHandle, ParamFileName, strlen(ParamFileName), &wrote, NULL);
+#endif
 			LogVar->ByteCount =
 				LogVar->ByteCount + strlen(ParamFileName);
 			FLogRefreshNum();



Ttssh2-commit メーリングリストの案内