Index: teraterm/teraterm/ttdebug.cpp =================================================================== --- teraterm/teraterm/ttdebug.cpp (リビジョン 9726) +++ teraterm/teraterm/ttdebug.cpp (作業コピー) @@ -283,7 +283,7 @@ return; } - logdir = GetLogDirW(); + logdir = GetLogDirW(NULL); awcscats(&dumpfile, logdir, L"\\", filename, NULL); HANDLE file = CreateFileW(dumpfile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); free(dumpfile); Index: teraterm/common/ttlib.h =================================================================== --- teraterm/common/ttlib.h (リビジョン 9726) +++ teraterm/common/ttlib.h (作業コピー) @@ -94,7 +94,7 @@ wchar_t *GetDownloadFolderW(void); wchar_t *GetHomeDirW(HINSTANCE hInst); wchar_t *GetExeDirW(HINSTANCE hInst); -wchar_t* GetLogDirW(void); +wchar_t* GetLogDirW(HINSTANCE hInst); wchar_t *GetDefaultFNameW(const wchar_t *home, const wchar_t *file); wchar_t *GetDefaultSetupFNameW(const wchar_t *home); void GetUILanguageFileFull(const char *HomeDir, const char *UILanguageFileRel, Index: teraterm/common/ttlib_static_cpp.cpp =================================================================== --- teraterm/common/ttlib_static_cpp.cpp (リビジョン 9726) +++ teraterm/common/ttlib_static_cpp.cpp (作業コピー) @@ -902,13 +902,18 @@ return dir; } +#define PORTABLE_FILENAME L"portable.ini" + /* * Get home directory * 個人用設定ファイルフォルダ取得 * ttypes.HomeDirW と同一 * TERATERM.INI などがおいてあるフォルダ - * ttermpro.exe があるフォルダは GetExeDirW() で取得 - * %APPDATA%\teraterm5 (%USERPROFILE%\AppData\Roaming\teraterm5) + * ttermpro.exe があるフォルダは GetHomeDirW() ではなく GetExeDirW() で取得できる + * ExeDirW に portable.ini がある場合 + * ExeDirW + * ExeDirW に portable.ini がない場合 + * %APPDATA%\teraterm5 (%USERPROFILE%\AppData\Roaming\teraterm5) * * @param[in] hInst WinMain()の HINSTANCE または NULL * @return HomeDir 不要になったら free() すること @@ -916,8 +921,17 @@ wchar_t *GetHomeDirW(HINSTANCE hInst) { wchar_t *path; + wchar_t *ret = NULL; + wchar_t *ExeDirW = GetExeDirW(hInst); + wchar_t *portable_file = NULL; + struct _stat s; + awcscats(&portable_file, ExeDirW, L"\\" PORTABLE_FILENAME, NULL); + if (_wstat(portable_file, &s) == 0) { + free(portable_file); + return ExeDirW; + } + free(portable_file); _SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &path); - wchar_t *ret = NULL; awcscats(&ret, path, L"\\teraterm5", NULL); free(path); return ret; @@ -927,16 +941,30 @@ * Get log directory * ログ保存フォルダ取得 * ttypes.LogDirW と同一 - * %LOCALAPPDATA%\teraterm5 (%USERPROFILE%\AppData\Local\teraterm5) + * ExeDirW に portable.ini がある場合 + * ExeDirW\log + * ExeDirW に portable.ini がない場合 + * %LOCALAPPDATA%\teraterm5 (%USERPROFILE%\AppData\Local\teraterm5) * * @param[in] hInst WinMain()の HINSTANCE または NULL * @return LogDir 不要になったら free() すること */ -wchar_t* GetLogDirW(void) +wchar_t* GetLogDirW(HINSTANCE hInst) { wchar_t *path; + wchar_t *ret = NULL; + wchar_t *ExeDirW = GetExeDirW(hInst); + wchar_t *portable_file = NULL; + struct _stat s; + awcscats(&portable_file, ExeDirW, L"\\" PORTABLE_FILENAME, NULL); + if (_wstat(portable_file, &s) == 0) { + awcscats(&ret, ExeDirW, L"\\log", NULL); + free(portable_file); + free(ExeDirW); + return ret; + } + free(portable_file); _SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &path); - wchar_t *ret = NULL; awcscats(&ret, path, L"\\teraterm5", NULL); free(path); return ret; Index: teraterm/ttpcmn/ttcmn.c =================================================================== --- teraterm/ttpcmn/ttcmn.c (リビジョン 9726) +++ teraterm/ttpcmn/ttcmn.c (作業コピー) @@ -202,7 +202,7 @@ ts->ExeDirW = GetExeDirW(hInst); // LogDir - ts->LogDirW = GetLogDirW(); + ts->LogDirW = GetLogDirW(hInst); CreateDirectoryW(ts->LogDirW, NULL); // HomeDir Index: ttssh2/ttxssh/ttxssh.c =================================================================== --- ttssh2/ttxssh/ttxssh.c (リビジョン 9726) +++ ttssh2/ttxssh/ttxssh.c (作業コピー) @@ -2565,7 +2565,7 @@ return _wcsdup(basename); } - path = GetLogDirW(); + path = GetLogDirW(NULL); awcscats(&path, L"\\", basename, NULL); return path; } Index: installer/makearchive.bat =================================================================== --- installer/makearchive.bat (リビジョン 9726) +++ installer/makearchive.bat (作業コピー) @@ -98,6 +98,7 @@ if "%release%"=="yes" ( copy nul %dst%\ttpmenu.ini +copy nul %dst%\portable.ini ) exit /b