diff --git a/doc/en/html/about/history.html b/doc/en/html/about/history.html
index 24c63ead2..5aea6b9b9 100644
--- a/doc/en/html/about/history.html
+++ b/doc/en/html/about/history.html
@@ -50,6 +50,7 @@
YYYY.MM.DD (Ver 5.4 not released yet)
Updated Unicode information to Unicode 16.0. Before update, Unicode 15.1 compliant since Tera Term 5.0.
All available character codes can be specified using command line options.
Supports "COM%d" style serial ports of com0com (virtual serial port driver), which are not Ports class.
+ Changed initial directory for file select dialog of send file to File transfer folder.
diff --git a/doc/ja/html/about/history.html b/doc/ja/html/about/history.html
index c1bbe14f7..6ce93778a 100644
--- a/doc/ja/html/about/history.html
+++ b/doc/ja/html/about/history.html
@@ -50,6 +50,7 @@ YYYY.MM.DD (Ver 5.4 not released yet)
Unicode の文字情報を Unicode 16.0 に更新した。更新前、Tera Term 5.0 から Unicode 15.1 準拠だった。
コマンドラインオプションで使用可能文字コードを全て指定できるようにした。
com0com(virtual serial port driver) の Ports class ではない "COM%d" 形式のシリアルポートを選択できるようにした。
+ 送信ファイルを選択するダイアログの初期ディレクトリがファイル転送用のフォルダになるようにした。
diff --git a/teraterm/teraterm/filesys_proto.cpp b/teraterm/teraterm/filesys_proto.cpp
index e6b230f52..2818fd032 100644
--- a/teraterm/teraterm/filesys_proto.cpp
+++ b/teraterm/teraterm/filesys_proto.cpp
@@ -688,7 +688,7 @@ wchar_t **MakeFileArrayMultiSelect(const wchar_t *lpstrFile)
static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPLONG Option)
{
- wchar_t *CurDir = GetFileDir(&ts);
+ wchar_t *FileDir = GetFileDir(&ts);
wchar_t *filterW = ToWcharA(ts.FileSendFilter);
wchar_t *FNFilter = GetCommonDialogFilterWW(!Receive ? filterW : NULL, ts.UILanguageFileW);
free(filterW);
@@ -696,7 +696,7 @@ static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPL
wchar_t FullName[MAX_PATH];
FullName[0] = 0;
if (!Receive) {
- wchar_t *default_filename = GetCommonDialogDefaultFilenameW(CurDir);
+ wchar_t *default_filename = GetCommonDialogDefaultFilenameW(FileDir);
if (default_filename != NULL) {
wcsncpy_s(FullName, _countof(FullName), default_filename, _TRUNCATE);
free(default_filename);
@@ -710,7 +710,7 @@ static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPL
ofn.nFilterIndex = 1;
ofn.lpstrFile = FullName;
ofn.nMaxFile = _countof(FullName);
- ofn.lpstrInitialDir = CurDir;
+ ofn.lpstrInitialDir = FileDir;
LONG opt = *Option;
if (! Receive)
{
@@ -740,7 +740,7 @@ static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPL
Ok = GetSaveFileNameW(&ofn);
}
free(FNFilter);
- free(CurDir);
+ free(FileDir);
SetCurrentDirectoryW(TempDir);
wchar_t **ret = NULL;
@@ -940,7 +940,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
#define FnStrMemSize 4096
wchar_t TempDir[MAX_PATH];
const wchar_t *UILanguageFileW = ts.UILanguageFileW;
- wchar_t *CurDir = GetFileDir(&ts);
+ wchar_t *FileDir = GetFileDir(&ts);
/* save current dir */
GetCurrentDirectoryW(_countof(TempDir), TempDir);
@@ -956,7 +956,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
wchar_t *FNFilter = GetCommonDialogFilterWW(filterW, UILanguageFileW);
free(filterW);
- wchar_t *default_filename = GetCommonDialogDefaultFilenameW(CurDir);
+ wchar_t *default_filename = GetCommonDialogDefaultFilenameW(FileDir);
if (default_filename != NULL) {
wcsncpy_s(FnStrMem, FnStrMemSize, default_filename, _TRUNCATE);
free(default_filename);
@@ -970,7 +970,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
ofn.lpstrFile = FnStrMem;
ofn.nMaxFile = FnStrMemSize;
ofn.lpstrTitle= caption;
- ofn.lpstrInitialDir = CurDir;
+ ofn.lpstrInitialDir = FileDir;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.Flags |= OFN_ALLOWMULTISELECT | OFN_EXPLORER;
ofn.Flags |= OFN_SHOWHELP;
@@ -996,7 +996,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
ret = MakeFileArrayMultiSelect(FnStrMem);
}
free(FnStrMem);
- free(CurDir);
+ free(FileDir);
/* restore dir */
SetCurrentDirectoryW(TempDir);
@@ -1504,7 +1504,7 @@ static wchar_t **_GetTransFname(HWND hWnd, const wchar_t *DlgCaption)
wchar_t TempDir[MAX_PATH];
wchar_t FileName[MAX_PATH];
const wchar_t *UILanguageFileW = ts.UILanguageFileW;
- wchar_t *CurDir = GetFileDir(&ts);
+ wchar_t *FileDir = GetFileDir(&ts);
/* save current dir */
GetCurrentDirectoryW(_countof(TempDir), TempDir);
@@ -1521,14 +1521,14 @@ static wchar_t **_GetTransFname(HWND hWnd, const wchar_t *DlgCaption)
ofn.nFilterIndex = 1;
ofn.lpstrFile = FileName;
ofn.nMaxFile = _countof(FileName);
- ofn.lpstrInitialDir = CurDir;
+ ofn.lpstrInitialDir = FileDir;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_SHOWHELP;
ofn.lpstrTitle = DlgCaption;
ofn.hInstance = hInst;
BOOL Ok = GetOpenFileNameW(&ofn);
free(FNFilter);
- free(CurDir);
+ free(FileDir);
wchar_t **ret = NULL;
if (Ok) {
diff --git a/teraterm/teraterm/sendfiledlg.cpp b/teraterm/teraterm/sendfiledlg.cpp
index 700edaa22..94ad31089 100644
--- a/teraterm/teraterm/sendfiledlg.cpp
+++ b/teraterm/teraterm/sendfiledlg.cpp
@@ -37,6 +37,7 @@
#include "i18n.h"
#include "tt_res.h"
#include "ttlib.h"
+#include "ttlib_types.h"
#include "dlglib.h"
#include "tttypes.h" // for WM_USER_DLGHELP2
#include "helpid.h"
@@ -178,6 +179,8 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA
free(uimsg);
uimsg = NULL;
+ TTTSet *ts = data->pts;
+ wchar_t *FileDir = GetFileDir(ts);
wchar_t *filterW = GetCommonDialogFilterWW(data->filesend_filter, data->UILanguageFileW);
wchar_t filename[MAX_PATH];
filename[0] = 0;
@@ -189,8 +192,10 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA
ofn.lpstrFilter = filterW;
ofn.nFilterIndex = 0;
ofn.lpstrTitle = title;
+ ofn.lpstrInitialDir = FileDir;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_SHOWHELP | OFN_HIDEREADONLY;
BOOL Ok = GetOpenFileNameW(&ofn);
+ free(FileDir);
free(filterW);
free(title);
diff --git a/teraterm/teraterm/sendfiledlg.h b/teraterm/teraterm/sendfiledlg.h
index 22ae0a0c2..558da3f61 100644
--- a/teraterm/teraterm/sendfiledlg.h
+++ b/teraterm/teraterm/sendfiledlg.h
@@ -37,6 +37,7 @@ typedef struct {
// in
const wchar_t* UILanguageFileW;
const wchar_t *filesend_filter;
+ TTTSet *pts;
// out
wchar_t* filename; // IDOK時、選択ファイル名が返る,使用後free()すること
BOOL binary; // TRUE/FALSE = バイナリ/テキスト
diff --git a/teraterm/teraterm/vtwin.cpp b/teraterm/teraterm/vtwin.cpp
index 777bbd694..3e23f932c 100644
--- a/teraterm/teraterm/vtwin.cpp
+++ b/teraterm/teraterm/vtwin.cpp
@@ -3972,6 +3972,7 @@ void CVTWindow::OnFileSend()
data.UILanguageFileW = ts.UILanguageFileW;
wchar_t *filterW = ToWcharA(ts.FileSendFilter);
data.filesend_filter = filterW;
+ data.pts = &ts;
INT_PTR ok = sendfiledlg(m_hInst, m_hWnd, &data);
free(filterW);
if (ok != IDOK) {