Skip to content

Commit

Permalink
[Refactor] #3236 open_dir_explorer() の引数をchar* からstring_view に変えた
Browse files Browse the repository at this point in the history
  • Loading branch information
Hourier authored and sikabane-works committed Jan 28, 2024
1 parent 977ebdb commit 29e28f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/main-win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,9 +1906,9 @@ static void process_menus(PlayerType *player_ptr, WORD wCmd)
break;
}
case IDM_OPTIONS_OPEN_MUSIC_DIR: {
std::vector<char> buf(MAIN_WIN_MAX_PATH);
path_build(&buf[0], MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
open_dir_in_explorer(&buf[0]);
char buf[MAIN_WIN_MAX_PATH];
path_build(buf, MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
open_dir_in_explorer(buf);
break;
}
case IDM_OPTIONS_SOUND: {
Expand All @@ -1930,9 +1930,9 @@ static void process_menus(PlayerType *player_ptr, WORD wCmd)
break;
}
case IDM_OPTIONS_OPEN_SOUND_DIR: {
std::vector<char> buf(MAIN_WIN_MAX_PATH);
path_build(&buf[0], MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
open_dir_in_explorer(&buf[0]);
char buf[MAIN_WIN_MAX_PATH];
path_build(buf, MAIN_WIN_MAX_PATH, ANGBAND_DIR_XTRA_SOUND, "sound.cfg");
open_dir_in_explorer(buf);
break;
}
case IDM_OPTIONS_NO_BG: {
Expand Down
7 changes: 4 additions & 3 deletions src/main-win/main-win-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ void save_screen_as_html(HWND hWnd)
* @brief 対象ファイルを選択した状態でエクスプローラーを開く
* @param filename 対象ファイル
*/
void open_dir_in_explorer(char *filename)
void open_dir_in_explorer(std::string_view filename)
{
std::string str = "/select," + std::string(filename);
ShellExecuteW(NULL, NULL, L"explorer.exe", to_wchar(str.data()).wc_str(), NULL, SW_SHOWNORMAL);
std::stringstream ss;
ss << "/select," << filename;
ShellExecuteW(NULL, NULL, L"explorer.exe", to_wchar(ss.str().data()).wc_str(), NULL, SW_SHOWNORMAL);
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/main-win/main-win-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ class to_multibyte {

bool is_already_running(void);
void save_screen_as_html(HWND hWnd);
void open_dir_in_explorer(char *filename);
void open_dir_in_explorer(std::string_view filename);
std::optional<std::string> get_open_filename(OPENFILENAMEW *ofn, const std::filesystem::path &dirname, std::string_view filename, DWORD max_name_size);

0 comments on commit 29e28f9

Please sign in to comment.