Revision: 7951 https://osdn.net/projects/ttssh2/scm/svn/commits/7951 Author: maya Date: 2019-08-14 00:29:48 +0900 (Wed, 14 Aug 2019) Log Message: ----------- FileDir を使用するとき、環境変数を展開するようにした #39456 Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/39456 Modified Paths: -------------- trunk/doc/en/html/about/history.html trunk/doc/en/html/menu/file-chdir.html trunk/doc/ja/html/about/history.html trunk/doc/ja/html/menu/file-chdir.html trunk/teraterm/teraterm/filesys.cpp trunk/teraterm/ttpdlg/ttdlg.c trunk/teraterm/ttpset/ttset.c trunk/ttssh2/ttxssh/ssh.c trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/doc/en/html/about/history.html =================================================================== --- trunk/doc/en/html/about/history.html 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/doc/en/html/about/history.html 2019-08-13 15:29:48 UTC (rev 7951) @@ -37,6 +37,7 @@ <ul> <li>MARCO: The <a href="../macro/command/fileopen.html">fileopen</a> command does not cause an error when a file can not be opened. Reverted changes in Ver 4.102.</li> <!--li><a href="../macro/command/filetruncate.html">filetruncate</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xAA\x82Ńt\x83@\x83\x8B\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA2\x8Fꍇ\x81E\x83t\x83@\x83C\x83\x8B\x83T\x83C\x83Y\x82̕ύX\x82Ɏ\xB8\x94s\x82\xB5\x82\xBD\x8Fꍇ\x83G\x83\x89\x81[\x82ɂȂ\xE7\x82Ȃ\xA2\x82悤\x82ɂ\xB5\x82\xBD\x81B</li--> + <!--li><a href="../menu/file-chdir.html">\x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x82̂\xBD\x82߂̃f\x83B\x83\x8C\x83N\x83g\x83\x8A</a>\x82Ɋ܂܂\xEA\x82\xE9\x8A\xAB\x95ϐ\x94\x82\xF0\x93W\x8AJ\x82\xB7\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li--> <li>Unspecified string font in IME uses your defined font.</li> <!--li><a href="../setup/teraterm-win.html#textselect">Disabling text selection when the window is activated by mouse</a>\x82\xF0<a href="../menu/setup-additional.html#SelectOnActivate">\x83_\x83C\x83A\x83\x8D\x83O</a>\x82Őݒ\xE8\x82ł\xAB\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li--> </ul> Modified: trunk/doc/en/html/menu/file-chdir.html =================================================================== --- trunk/doc/en/html/menu/file-chdir.html 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/doc/en/html/menu/file-chdir.html 2019-08-13 15:29:48 UTC (rev 7951) @@ -16,7 +16,8 @@ <h2>"Change directory" dialog box</h2> <p> - Enter a new directory name. + Enter a new directory name.<br /> + <!--\x82\xB1\x82̐ݒ\xE8\x92l\x82\xAA\x8Eg\x97p\x82\xB3\x82\xEA\x82\xE9\x82Ƃ\xAB\x81A\x8A\xAB\x95ϐ\x94\x82\xAA\x8A܂܂\xEA\x82Ă\xA2\x82\xEA\x82ΓW\x8AJ\x82\xB3\x82\xEA\x82܂\xB7\x81B--> </p> </body> </html> Modified: trunk/doc/ja/html/about/history.html =================================================================== --- trunk/doc/ja/html/about/history.html 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/doc/ja/html/about/history.html 2019-08-13 15:29:48 UTC (rev 7951) @@ -37,6 +37,7 @@ <ul> <li><a href="../macro/command/fileopen.html">fileopen</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82ŁA\x83t\x83@\x83C\x83\x8B\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA2\x8Fꍇ\x82ɃG\x83\x89\x81[\x82ɂȂ\xE7\x82Ȃ\xA2\x82悤\x82ɂ\xB5\x82\xBD\x81BVer 4.102\x82ł̕ύX\x82\xF0\x8C\xB3\x82ɖ߂\xB5\x82\xBD\x81B</li> <li><a href="../macro/command/filetruncate.html">filetruncate</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xAA\x82Ńt\x83@\x83\x8B\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA2\x8Fꍇ\x81E\x83t\x83@\x83C\x83\x8B\x83T\x83C\x83Y\x82̕ύX\x82Ɏ\xB8\x94s\x82\xB5\x82\xBD\x8Fꍇ\x83G\x83\x89\x81[\x82ɂȂ\xE7\x82Ȃ\xA2\x82悤\x82ɂ\xB5\x82\xBD\x81B</li> + <li><a href="../menu/file-chdir.html">\x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x82̂\xBD\x82߂̃f\x83B\x83\x8C\x83N\x83g\x83\x8A</a>\x82Ɋ܂܂\xEA\x82\xE9\x8A\xAB\x95ϐ\x94\x82\xF0\x93W\x8AJ\x82\xB7\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li> <li>IME\x82̖\xA2\x8Am\x92蕶\x8E\x9A\x82̃t\x83H\x83\x93\x83g\x82\xAA\x8Ew\x92\xE8\x83t\x83H\x83\x93\x83g\x82Ɠ\xAF\x88\xEA\x82ɂȂ\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li> <li><a href="../setup/teraterm-win.html#textselect">\x83}\x83E\x83X\x82ŃE\x83B\x83\x93\x83h\x83E\x82\xF0\x91I\x91\xF0\x82\xB5\x82\xBD\x82Ƃ\xAB\x82̕\xB6\x8E\x9A\x82̑I\x91\xF0\x82\xF0\x8B֎~\x82\xB7\x82\xE9</a>\x82\xF0<a href="../menu/setup-additional.html#SelectOnActivate">\x83_\x83C\x83A\x83\x8D\x83O</a>\x82Őݒ\xE8\x82ł\xAB\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li> </ul> Modified: trunk/doc/ja/html/menu/file-chdir.html =================================================================== --- trunk/doc/ja/html/menu/file-chdir.html 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/doc/ja/html/menu/file-chdir.html 2019-08-13 15:29:48 UTC (rev 7951) @@ -16,7 +16,8 @@ <h2>"Change directory" \x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X</h2> <p> - \x90V\x82\xB5\x82\xA2\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xF0\x93\xFC\x97͂\xB5\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B + \x90V\x82\xB5\x82\xA2\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xF0\x93\xFC\x97͂\xB5\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B<br /> + \x82\xB1\x82̐ݒ\xE8\x92l\x82\xAA\x8Eg\x97p\x82\xB3\x82\xEA\x82\xE9\x82Ƃ\xAB\x81A\x8A\xAB\x95ϐ\x94\x82\xAA\x8A܂܂\xEA\x82Ă\xA2\x82\xEA\x82ΓW\x8AJ\x82\xB3\x82\xEA\x82܂\xB7\x81B </p> </body> </html> Modified: trunk/teraterm/teraterm/filesys.cpp =================================================================== --- trunk/teraterm/teraterm/filesys.cpp 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/teraterm/teraterm/filesys.cpp 2019-08-13 15:29:48 UTC (rev 7951) @@ -318,8 +318,10 @@ *fv = (PFileVar)malloc(sizeof(TFileVar)); if ((*fv)!=NULL) { + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); memset(*fv, 0, sizeof(TFileVar)); - strncpy_s((*fv)->FullName, sizeof((*fv)->FullName),ts.FileDir, _TRUNCATE); + strncpy_s((*fv)->FullName, sizeof((*fv)->FullName), FileDirExpanded, _TRUNCATE); AppendSlash((*fv)->FullName,sizeof((*fv)->FullName)); (*fv)->DirLen = strlen((*fv)->FullName); (*fv)->FileOpen = FALSE; @@ -490,6 +492,7 @@ char buf[512]; const char *crlf = "\r\n"; DWORD crlf_len = 2; + char FileDirExpanded[MAX_PATH]; if ((FileLog) || (BinLog)) return FALSE; @@ -505,7 +508,8 @@ logdir = ts.LogDefaultPath; } else if (strlen(ts.FileDir) > 0) { - logdir = ts.FileDir; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); + logdir = FileDirExpanded; } else { logdir = ts.HomeDir; @@ -1174,11 +1178,13 @@ FSend = TRUE; - if (strlen(&(SendVar->FullName[SendVar->DirLen]))==0) { + if (strlen(&(SendVar->FullName[SendVar->DirLen])) == 0) { + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); if (ts.TransBin) Option |= LOGDLG_BINARY; SendVar->FullName[0] = 0; - if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option)) { + if (! (*GetTransFname)(SendVar, FileDirExpanded, GTF_SEND, &Option)) { FileTransEnd(OpSendFile); return; } @@ -1632,7 +1638,9 @@ FileVar->OpId = OpKmtSend; if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) { - if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_KERMIT,&w) || + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); + if (!(*GetMultiFname)(FileVar, FileDirExpanded, GMF_KERMIT, &w) || (FileVar->NumFname==0)) { ProtoEnd(); @@ -1690,9 +1698,11 @@ if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) { + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); Option = MAKELONG(ts.XmodemBin,ts.XmodemOpt); if (! (*GetXFname)(FileVar->HMainWin, - mode==IdXReceive,&Option,FileVar,ts.FileDir)) + mode==IdXReceive,&Option,FileVar,FileDirExpanded)) { ProtoEnd(); return; @@ -1769,6 +1779,9 @@ if (mode==IdYSend) { + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); + // \x83t\x83@\x83C\x83\x8B\x93]\x91\x97\x8E\x9E\x82̃I\x83v\x83V\x83\x87\x83\x93\x82\xCD"Yopt1K"\x82Ɍ\x88\x82ߑł\xBF\x81B // TODO: "Yopt1K", "YoptG", "YoptSingle"\x82\xF0\x8B\xE6\x95ʂ\xB5\x82\xBD\x82\xA2\x82Ȃ\xE7\x82AIDD_FOPT\x82\xF0\x8Ag\x92\xA3\x82\xB7\x82\xE9\x95K\x97v\x82\xA0\x82\xE8\x81B Opt = Yopt1K; @@ -1775,7 +1788,7 @@ FileVar->OpId = OpYSend; if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) { - if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_Y,&Opt) || + if (! (*GetMultiFname)(FileVar,FileDirExpanded,GMF_Y,&Opt) || (FileVar->NumFname==0)) { ProtoEnd(); @@ -1815,7 +1828,9 @@ FileVar->OpId = OpZSend; if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) { - if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_Z,&Opt) || + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); + if (! (*GetMultiFname)(FileVar,FileDirExpanded,GMF_Z,&Opt) || (FileVar->NumFname==0)) { if (mode == IdZAutoS) { @@ -1852,8 +1867,10 @@ FileVar->OpId = OpBPSend; if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) { + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); FileVar->FullName[0] = 0; - if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option)) + if (! (*GetTransFname)(FileVar, FileDirExpanded, GTF_BP, &Option)) { ProtoEnd(); return; @@ -1886,7 +1903,9 @@ FileVar->OpId = OpQVSend; if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) { - if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_QV, &W) || + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded)); + if (! (*GetMultiFname)(FileVar,FileDirExpanded,GMF_QV, &W) || (FileVar->NumFname==0)) { ProtoEnd(); Modified: trunk/teraterm/ttpdlg/ttdlg.c =================================================================== --- trunk/teraterm/ttpdlg/ttdlg.c 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/teraterm/ttpdlg/ttdlg.c 2019-08-13 15:29:48 UTC (rev 7951) @@ -1829,11 +1829,14 @@ case IDOK: CurDir = (PCHAR)GetWindowLongPtr(Dialog,DWLP_USER); if ( CurDir!=NULL ) { + char FileDirExpanded[MAX_PATH]; _getcwd(HomeDir,sizeof(HomeDir)); - _chdir(CurDir); + ExpandEnvironmentStrings(CurDir, FileDirExpanded, sizeof(FileDirExpanded)); + _chdir(FileDirExpanded); GetDlgItemText(Dialog, IDC_DIRNEW, TmpDir, sizeof(TmpDir)); if ( strlen(TmpDir)>0 ) { - if (_chdir(TmpDir) != 0) { + ExpandEnvironmentStrings(TmpDir, FileDirExpanded, sizeof(FileDirExpanded)); + if (_chdir(FileDirExpanded) != 0) { get_lang_msg("MSG_TT_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", UILanguageFile); get_lang_msg("MSG_FIND_DIR_ERROR", uimsg, sizeof(uimsg), "Cannot find directory", UILanguageFile); MessageBox(Dialog,uimsg,uimsg2,MB_ICONEXCLAMATION); @@ -1840,7 +1843,7 @@ _chdir(HomeDir); return TRUE; } - _getcwd(CurDir,MAXPATHLEN); + strncpy_s(CurDir, MAXPATHLEN, TmpDir, _TRUNCATE); } _chdir(HomeDir); } @@ -1854,9 +1857,13 @@ case IDC_SELECT_DIR: get_lang_msg("DLG_SELECT_DIR_TITLE", uimsg, sizeof(uimsg), "Select new directory", UILanguageFile); - GetDlgItemText(Dialog, IDC_DIRNEW, buf, sizeof(buf)); - if (doSelectFolder(Dialog, buf2, sizeof(buf2), buf, uimsg)) { - SetDlgItemText(Dialog, IDC_DIRNEW, buf2); + { + char FileDirExpanded[MAX_PATH]; + GetDlgItemText(Dialog, IDC_DIRNEW, buf, sizeof(buf)); + ExpandEnvironmentStrings(buf, FileDirExpanded, sizeof(FileDirExpanded)); + if (doSelectFolder(Dialog, buf2, sizeof(buf2), FileDirExpanded, uimsg)) { + SetDlgItemText(Dialog, IDC_DIRNEW, buf2); + } } return TRUE; Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/teraterm/ttpset/ttset.c 2019-08-13 15:29:48 UTC (rev 7951) @@ -1190,8 +1190,10 @@ if (strlen(ts->FileDir) == 0) GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir)); else { + char FileDirExpanded[MAX_PATH]; + ExpandEnvironmentStrings(ts->FileDir, FileDirExpanded, sizeof(FileDirExpanded)); _getcwd(Temp, sizeof(Temp)); - if (_chdir(ts->FileDir) != 0) + if (_chdir(FileDirExpanded) != 0) GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir)); _chdir(Temp); } Modified: trunk/ttssh2/ttxssh/ssh.c =================================================================== --- trunk/ttssh2/ttxssh/ssh.c 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/ttssh2/ttxssh/ssh.c 2019-08-13 15:29:48 UTC (rev 7951) @@ -4071,18 +4071,16 @@ strncpy_s(c->scp.remotefile, sizeof(c->scp.remotefile), sendfile, _TRUNCATE); if (dstfile == NULL || dstfile[0] == '\0') { // local file path is empty. - char *fn, *cwd; + char *fn; + char FileDirExpanded[MAX_PATH]; fn = strrchr(sendfile, '/'); if (fn && fn[1] == '\0') goto error; - cwd = pvar->ts->FileDir; - //cwd = _getcwd(NULL, 0); - _snprintf_s(c->scp.localfilefull, sizeof(c->scp.localfilefull), _TRUNCATE, "%s\\%s", cwd, fn ? fn : sendfile); + ExpandEnvironmentStrings(pvar->ts->FileDir, FileDirExpanded, sizeof(FileDirExpanded)); + _snprintf_s(c->scp.localfilefull, sizeof(c->scp.localfilefull), _TRUNCATE, "%s\\%s", FileDirExpanded, fn ? fn : sendfile); ExtractFileName(c->scp.localfilefull, c->scp.localfile, sizeof(c->scp.localfile)); // file name only - - //free(cwd); // free!! } else { _snprintf_s(c->scp.localfilefull, sizeof(c->scp.localfilefull), _TRUNCATE, "%s", dstfile); ExtractFileName(dstfile, c->scp.localfile, sizeof(c->scp.localfile)); // file name only Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2019-08-13 15:09:07 UTC (rev 7950) +++ trunk/ttssh2/ttxssh/ttxssh.c 2019-08-13 15:29:48 UTC (rev 7951) @@ -3919,6 +3919,7 @@ char recvpath[MAX_PATH] = ""; char* fn = strrchr(szFileName, '/'); char recvfn[sizeof(szFileName)]; + char recvdir_expanded[MAX_PATH]; // \x91\x97\x90M\x83p\x83X\x82\xF0\x8E\xE6\x82\xE8\x8Fo\x82\xB5\x81Ats->ScpSendDir \x82\xE0\x8D\x87\x82킹\x82čX\x90V\x82\xB7\x82\xE9\x81B hWnd = GetDlgItem(dlg, IDC_SENDFILE_TO); @@ -3928,6 +3929,7 @@ // \x8E\xF3\x90M\x83p\x83X\x82\xF0\x8E\xE6\x82\xE8\x8Fo\x82\xB5\x81Ats->FileDir \x82\xE0\x8D\x87\x82킹\x82čX\x90V\x82\xB7\x82\xE9\x81B hWnd = GetDlgItem(dlg, IDC_RECVFILE_TO); SendMessage(hWnd, WM_GETTEXT , sizeof(recvdir), (LPARAM)recvdir); + ExpandEnvironmentStrings(recvdir, recvdir_expanded, sizeof(recvdir_expanded)); strncpy_s(pvar->ts->FileDir, sizeof(pvar->ts->FileDir), recvdir, _TRUNCATE); if (fn) { @@ -3941,7 +3943,7 @@ } strncpy_s(recvfn, sizeof(recvfn), fn, _TRUNCATE); replaceInvalidFileNameChar(recvfn, '_'); - _snprintf_s(recvpath, sizeof(recvpath), _TRUNCATE, "%s\\%s", recvdir, recvfn); + _snprintf_s(recvpath, sizeof(recvpath), _TRUNCATE, "%s\\%s", recvdir_expanded, recvfn); SSH_scp_transaction(pvar, szFileName, recvpath, FROMREMOTE); EndDialog(dlg, 1); // dialog close return TRUE;