Revision: 9466 https://osdn.net/projects/ttssh2/scm/svn/commits/9466 Author: zmatsuo Date: 2021-10-14 23:51:37 +0900 (Thu, 14 Oct 2021) Log Message: ----------- tttset 構造体に ExeDirW と LogDirW を追加 - ttsset.ExeDirW - exeなどが置かれたフォルダ - tttset.HomeDirW - iniなどが置かれたフォルダ - ユーザー固有データ - tttset.LogDirW - log、ダンプなどが置かれたフォルダ Modified Paths: -------------- trunk/teraterm/common/tttypes.h trunk/teraterm/ttpcmn/ttcmn.c -------------- next part -------------- Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2021-10-14 14:51:28 UTC (rev 9465) +++ trunk/teraterm/common/tttypes.h 2021-10-14 14:51:37 UTC (rev 9466) @@ -361,7 +361,7 @@ struct tttset { /*------ VTSet --------*/ /* Tera Term home directory */ - char HomeDir[MAXPATHLEN]; // ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_ + char HomeDir[MAXPATHLEN]; // ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_(\x8Cl\x90ݒ\xE8\x83t\x83@\x83C\x83\x8B\x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_) /* Setup file name */ char SetupFName[MAX_PATH]; @@ -645,13 +645,15 @@ BYTE UnicodeAmbiguousWidth; BYTE UnicodeEmojiOverride; BYTE UnicodeEmojiWidth; - wchar_t *HomeDirW; // ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_ - wchar_t *SetupFNameW; - wchar_t *KeyCnfFNW; + wchar_t *HomeDirW; // ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_(\x8Cl\x90ݒ\xE8\x83t\x83@\x83C\x83\x8B\x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_) + wchar_t *SetupFNameW; // "TERATERM.INI" \x82̃t\x83\x8B\x83p\x83X + wchar_t *KeyCnfFNW; // "KEYBOARD.CNF" \x82̃t\x83\x8B\x83p\x83X wchar_t *LogFNW; wchar_t *MacroFNW; wchar_t *UILanguageFileW; // \x90\xE2\x91p\x83X wchar_t *UILanguageFileW_ini; // \x91\x8A\x91p\x83X,ini\x83t\x83@\x83C\x83\x8B\x82̒\x86\x90g + wchar_t *ExeDirW; // ttermpro.exe \x82̂\xA0\x82\xE9\x83t\x83H\x83\x8B\x83_ + wchar_t *LogDirW; // log\x82\xE2\x83_\x83\x93\x83v\x82\xF0\x92u\x82\xAD\x83t\x83H\x83\x8B\x83_ }; typedef struct tttset TTTSet, *PTTSet; Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2021-10-14 14:51:28 UTC (rev 9465) +++ trunk/teraterm/ttpcmn/ttcmn.c 2021-10-14 14:51:37 UTC (rev 9466) @@ -109,6 +109,17 @@ memcpy(&pm->ts, ts, sizeof(TTTSet)); } +static wchar_t* GetLogDirW() +{ + wchar_t *local_app_data; + wchar_t *log; + _SHGetKnownFolderPath(&FOLDERID_LocalAppData, 0, NULL, &local_app_data); + aswprintf(&log, L"%s\\%s", local_app_data, L"teraterm5"); + free(local_app_data); + CreateDirectoryW(log, NULL); + return log; +} + BOOL WINAPI StartTeraTerm(PTTSet ts) { if (FirstInstance) { @@ -128,6 +139,8 @@ // if (FirstInstance) { \x82̕\x94\x95\xAA\x82\xA9\x82\xE7\x88ړ\xAE (2008.3.13 maya) // \x8BN\x93\xAE\x8E\x9E\x82ɂ́A\x8B\xA4\x97L\x83\x81\x83\x82\x83\x8A\x82\xCC HomeDir \x82\xC6 SetupFName \x82͋\xF3\x82ɂȂ\xE9 /* Get home directory (ttermpro.exe\x82̃t\x83H\x83\x8B\x83_) */ + ts->ExeDirW = GetHomeDirW(hInst); + ts->LogDirW = GetLogDirW(); ts->HomeDirW = GetHomeDirW(hInst); WideCharToACP_t(ts->HomeDirW, ts->HomeDir, _countof(ts->HomeDir)); SetCurrentDirectoryW(ts->HomeDirW);