Revision: 9009 https://osdn.net/projects/ttssh2/scm/svn/commits/9009 Author: zmatsuo Date: 2020-11-02 00:38:33 +0900 (Mon, 02 Nov 2020) Log Message: ----------- FTCreateFile() を各モジュールへ移動 Modified Paths: -------------- branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp branches/proto_unicode/teraterm/ttpfile/bplus.c 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:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/teraterm/filesys_proto.cpp 2020-11-01 15:38:33 UTC (rev 9009) @@ -961,7 +961,6 @@ fv->FileNames = MakeStrArrayFromStr(filename); FileVar->NoMsg = TRUE; } -// GetNextFname(fv); KermitStart(IdKmtSend); return TRUE; @@ -1144,7 +1143,6 @@ ts.XmodemBin = ParamBinaryFlag; FileVar->NoMsg = TRUE; } - GetNextFname(fv); XMODEMStart(IdXReceive); fv->SetDlgProtoFileName(fv, fv->FullName); @@ -1219,7 +1217,6 @@ } FileVar->NoMsg = TRUE; } - GetNextFname(fv); XMODEMStart(IdXSend); fv->SetDlgProtoFileName(fv, fv->FullName); Modified: branches/proto_unicode/teraterm/ttpfile/bplus.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/bplus.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/bplus.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -572,7 +572,30 @@ return 0; } +static BOOL FTCreateFile(PFileVarProto fv) +{ + TFileIO *file = fv->file; + fv->SetDlgProtoFileName(fv, fv->FullName); + fv->FileOpen = file->OpenWrite(file, fv->FullName); + if (! fv->FileOpen) { + if (fv->NoMsg) { + MessageBox(fv->HMainWin,"Cannot create file", + "Tera Term: Error",MB_ICONEXCLAMATION); + } + return FALSE; + } + + fv->ByteCount = 0; + fv->FileSize = 0; + if (fv->ProgStat != -1) { + fv->ProgStat = 0; + } + fv->StartTime = GetTickCount(); + + return TRUE; +} + static void BPParseTPacket(PFileVarProto fv, PBPVar bv) { int i, j, c; Modified: branches/proto_unicode/teraterm/ttpfile/ftlib.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ftlib.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/ftlib.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -39,19 +39,6 @@ #include "ftlib.h" #include "tt_res.h" -void FTConvFName(PCHAR FName) -{ // replace ' ' by '_' in FName - int i; - - i = 0; - while (FName[i]!=0) - { - if (FName[i]==' ') - FName[i] = '_'; - i++; - } -} - BOOL GetNextFname(PFileVarProto fv) { const char *f = fv->FileNames[fv->FNCount]; @@ -97,71 +84,6 @@ SetTimer(fv->HMainWin, IdProtoTimer, T*1000, NULL); } -static void AddNum(PCHAR FName, int n) -{ - char Num[11]; - int i, j, k, dLen; - - _snprintf_s(Num,sizeof(Num),_TRUNCATE,"%u",n); - GetFileNamePos(FName,&i,&j); - k = strlen(FName); - while ((k>j) && (FName[k]!='.')) - k--; - if (FName[k]!='.') k = strlen(FName); - dLen = strlen(Num); - - if (strlen(FName)+dLen > MAX_PATH - 1) - dLen = MAX_PATH - 1 - strlen(FName); - memmove(&FName[k+dLen],&FName[k],strlen(FName)-k+1); - memcpy(&FName[k+dLen-strlen(Num)],Num,strlen(Num)); -} - -BOOL FTCreateFile(PFileVarProto fv) -{ - int i; - char Temp[MAX_PATH]; - int DirLen; - TFileIO *file = fv->file; - - GetFileNamePos(fv->FullName, &DirLen, &i); - DirLen++; // \x88\xEA\x94ԍŌ\xE3\x82\xCC '\\' \x82\xF0\x8Ew\x82\xB5\x82Ă\xA2\x82\xE9\x82̂\xC5 +1 \x82\xB5\x82Ă\xA8\x82\xAD - - replaceInvalidFileNameChar(&(fv->FullName[DirLen]), '_'); - - if (fv->FullName[DirLen] == 0) { - strncpy_s(&(fv->FullName[DirLen]), sizeof(fv->FullName) - DirLen, "noname", _TRUNCATE); - } - - FitFileName(&(fv->FullName[DirLen]),sizeof(fv->FullName) - DirLen,NULL); - if (! fv->OverWrite) - { - i = 0; - strncpy_s(Temp, sizeof(Temp),fv->FullName, _TRUNCATE); - while (DoesFileExist(Temp)) - { - i++; - strncpy_s(Temp, sizeof(Temp),fv->FullName, _TRUNCATE); - AddNum(Temp,i); - } - strncpy_s(fv->FullName, sizeof(fv->FullName),Temp, _TRUNCATE); - } - fv->FileOpen = file->OpenWrite(file, fv->FullName); - if (! fv->FileOpen && ! fv->NoMsg) - MessageBox(fv->HMainWin,"Cannot create file", - "Tera Term: Error",MB_ICONEXCLAMATION); - fv->SetDlgProtoFileName(fv, fv->FullName); - fv->ByteCount = 0; - fv->FileSize = 0; - - if (fv->ProgStat != -1) { - fv->ProgStat = 0; - } - - fv->StartTime = GetTickCount(); - - return fv->FileOpen; -} - // // \x83v\x83\x8D\x83g\x83R\x83\x8B\x97p\x83\x8D\x83O // Modified: branches/proto_unicode/teraterm/ttpfile/ftlib.h =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ftlib.h 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/ftlib.h 2020-11-01 15:38:33 UTC (rev 9009) @@ -36,12 +36,10 @@ #endif void GetLongFName(PCHAR FullName, PCHAR LongName, int destlen); -void FTConvFName(PCHAR FName); BOOL GetNextFname(PFileVarProto fv); WORD UpdateCRC(BYTE b, WORD CRC); LONG UpdateCRC32(BYTE b, LONG CRC); void FTSetTimeOut(PFileVarProto fv, int T); -BOOL FTCreateFile(PFileVarProto fv); typedef struct ProtoLog { // public Modified: branches/proto_unicode/teraterm/ttpfile/kermit.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/kermit.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/kermit.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -1315,6 +1315,30 @@ } } +static BOOL FTCreateFile(PFileVarProto fv) +{ + TFileIO *file = fv->file; + + fv->SetDlgProtoFileName(fv, fv->FullName); + fv->FileOpen = file->OpenWrite(file, fv->FullName); + if (! fv->FileOpen) { + if (fv->NoMsg) { + MessageBox(fv->HMainWin,"Cannot create file", + "Tera Term: Error",MB_ICONEXCLAMATION); + } + return FALSE; + } + + fv->ByteCount = 0; + fv->FileSize = 0; + if (fv->ProgStat != -1) { + fv->ProgStat = 0; + } + fv->StartTime = GetTickCount(); + + return TRUE; +} + static BOOL KmtReadPacket(PFileVarProto fv, PComVar cv) { BYTE b; Modified: branches/proto_unicode/teraterm/ttpfile/quickvan.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/quickvan.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/quickvan.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -416,6 +416,30 @@ return Ok; } +static BOOL FTCreateFile(PFileVarProto fv) +{ + TFileIO *file = fv->file; + + fv->SetDlgProtoFileName(fv, fv->FullName); + fv->FileOpen = file->OpenWrite(file, fv->FullName); + if (! fv->FileOpen) { + if (fv->NoMsg) { + MessageBox(fv->HMainWin,"Cannot create file", + "Tera Term: Error",MB_ICONEXCLAMATION); + } + return FALSE; + } + + fv->ByteCount = 0; + fv->FileSize = 0; + if (fv->ProgStat != -1) { + fv->ProgStat = 0; + } + fv->StartTime = GetTickCount(); + + return TRUE; +} + static BOOL QVParseVFILE(PFileVarProto fv, PQVVar qv) { TFileIO *file = fv->file; Modified: branches/proto_unicode/teraterm/ttpfile/xmodem.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/xmodem.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/xmodem.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -227,6 +227,7 @@ log->LogState = 0; } + GetNextFname(fv); fv->FileSize = 0; if (xv->XMode == IdXSend) { fv->FileOpen = file->OpenRead(file, fv->FullName); Modified: branches/proto_unicode/teraterm/ttpfile/ymodem.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/ymodem.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/ymodem.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -446,6 +446,30 @@ } } +static BOOL FTCreateFile(PFileVarProto fv) +{ + TFileIO *file = fv->file; + + fv->SetDlgProtoFileName(fv, fv->FullName); + fv->FileOpen = file->OpenWrite(file, fv->FullName); + if (! fv->FileOpen) { + if (fv->NoMsg) { + MessageBox(fv->HMainWin,"Cannot create file", + "Tera Term: Error",MB_ICONEXCLAMATION); + } + return FALSE; + } + + fv->ByteCount = 0; + fv->FileSize = 0; + if (fv->ProgStat != -1) { + fv->ProgStat = 0; + } + fv->StartTime = GetTickCount(); + + return TRUE; +} + // YMODEM\x83T\x81[\x83o\x82\xA9\x82\xE7\x83t\x83@\x83C\x83\x8B\x82\xF0\x8E\xF3\x90M\x82\xB7\x82\xE9\x8DہAProtoParse()\x82\xA9\x82\xE7\x8CĂяo\x82\xB3\x82\xEA\x82\xE9\x8A\x94\x81B // // +-------+-------+--------+---------+-----+ Modified: branches/proto_unicode/teraterm/ttpfile/zmodem.c =================================================================== --- branches/proto_unicode/teraterm/ttpfile/zmodem.c 2020-11-01 15:38:17 UTC (rev 9008) +++ branches/proto_unicode/teraterm/ttpfile/zmodem.c 2020-11-01 15:38:33 UTC (rev 9009) @@ -1038,6 +1038,30 @@ zv->PktInCount = 0; } +static BOOL FTCreateFile(PFileVarProto fv) +{ + TFileIO *file = fv->file; + + fv->SetDlgProtoFileName(fv, fv->FullName); + fv->FileOpen = file->OpenWrite(file, fv->FullName); + if (! fv->FileOpen) { + if (fv->NoMsg) { + MessageBox(fv->HMainWin,"Cannot create file", + "Tera Term: Error",MB_ICONEXCLAMATION); + } + return FALSE; + } + + fv->ByteCount = 0; + fv->FileSize = 0; + if (fv->ProgStat != -1) { + fv->ProgStat = 0; + } + fv->StartTime = GetTickCount(); + + return TRUE; +} + static BOOL ZParseFile(PFileVarProto fv, PZVar zv) { BYTE b;