mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 21:52:49 +00:00
ファイルの上書き禁止に対応
This commit is contained in:
parent
98e2567d07
commit
42ebfd4da7
@ -86,5 +86,6 @@
|
|||||||
"MessageAllFileFolder":"All files and folders(*.*)",
|
"MessageAllFileFolder":"All files and folders(*.*)",
|
||||||
"MessageTitleInputDialog":"Please select input file or folder",
|
"MessageTitleInputDialog":"Please select input file or folder",
|
||||||
"MessageTimeLeftUnkown":"Time Left: Unkown",
|
"MessageTimeLeftUnkown":"Time Left: Unkown",
|
||||||
"MessageTimeLeft":"Time Left"
|
"MessageTimeLeft":"Time Left",
|
||||||
|
"MessageNoOverwrite":"Already file exists in the destination: %s"
|
||||||
}
|
}
|
||||||
|
@ -86,5 +86,6 @@
|
|||||||
"MessageAllFileFolder":"すべてのファイル、フォルダ(*.*)",
|
"MessageAllFileFolder":"すべてのファイル、フォルダ(*.*)",
|
||||||
"MessageTitleInputDialog":"入力するファイルかフォルダを選択してください",
|
"MessageTitleInputDialog":"入力するファイルかフォルダを選択してください",
|
||||||
"MessageTimeLeftUnkown":"残り時間: 不明",
|
"MessageTimeLeftUnkown":"残り時間: 不明",
|
||||||
"MessageTimeLeft":"残り時間"
|
"MessageTimeLeft":"残り時間",
|
||||||
|
"MessageNoOverwrite":"出力先に既にファイルが存在します: %s"
|
||||||
}
|
}
|
||||||
|
@ -690,6 +690,18 @@ void DialogEvent::ProcessWaifu2x()
|
|||||||
const auto fileNum = file_paths.size();
|
const auto fileNum = file_paths.size();
|
||||||
for (const auto &p : file_paths)
|
for (const auto &p : file_paths)
|
||||||
{
|
{
|
||||||
|
if (isOutputNoOverwrite && boost::filesystem::exists(p.second)) // 上書き禁止ならメッセージ表示して無視
|
||||||
|
{
|
||||||
|
SendMessage(dh, WM_ON_WAIFU2X_NO_OVERWRITE, (WPARAM)p.first.c_str(), (LPARAM)p.second.c_str());
|
||||||
|
|
||||||
|
num++;
|
||||||
|
ProgessFunc(maxFile, num);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ret = w.waifu2x(p.first, p.second, [this]()
|
ret = w.waifu2x(p.first, p.second, [this]()
|
||||||
{
|
{
|
||||||
return cancelFlag;
|
return cancelFlag;
|
||||||
@ -1272,6 +1284,17 @@ void DialogEvent::OnWaifu2xError(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogEvent::OnWaifu2xNoOverwrite(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
|
||||||
|
{
|
||||||
|
const TCHAR *input = (const TCHAR *)wParam;
|
||||||
|
const TCHAR *output = (const TCHAR *)lParam;
|
||||||
|
|
||||||
|
TCHAR msg[1024] = TEXT("");
|
||||||
|
_stprintf(msg, langStringList.GetString(L"MessageNoOverwrite").c_str(), output);
|
||||||
|
|
||||||
|
AddLogMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
void DialogEvent::SetWindowTextLang()
|
void DialogEvent::SetWindowTextLang()
|
||||||
{
|
{
|
||||||
#define SET_WINDOW_TEXT(id) SetWindowTextW(GetDlgItem(dh, id), langStringList.GetString(L#id).c_str());
|
#define SET_WINDOW_TEXT(id) SetWindowTextW(GetDlgItem(dh, id), langStringList.GetString(L#id).c_str());
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#define WM_FAILD_CREATE_DIR (WM_APP + 5)
|
#define WM_FAILD_CREATE_DIR (WM_APP + 5)
|
||||||
#define WM_ON_WAIFU2X_ERROR (WM_APP + 6)
|
#define WM_ON_WAIFU2X_ERROR (WM_APP + 6)
|
||||||
|
#define WM_ON_WAIFU2X_NO_OVERWRITE (WM_APP + 8)
|
||||||
#define WM_END_THREAD (WM_APP + 7)
|
#define WM_END_THREAD (WM_APP + 7)
|
||||||
|
|
||||||
|
|
||||||
@ -169,6 +170,8 @@ public:
|
|||||||
|
|
||||||
void OnWaifu2xError(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData);
|
void OnWaifu2xError(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData);
|
||||||
|
|
||||||
|
void OnWaifu2xNoOverwrite(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData);
|
||||||
|
|
||||||
void SetWindowTextLang();
|
void SetWindowTextLang();
|
||||||
|
|
||||||
void SetDepthAndQuality(const bool SetDefaultQuality = true);
|
void SetDepthAndQuality(const bool SetDefaultQuality = true);
|
||||||
|
@ -96,6 +96,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
|||||||
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnDialogEnd, &cDialogEvent), NULL, WM_CLOSE);
|
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnDialogEnd, &cDialogEvent), NULL, WM_CLOSE);
|
||||||
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnFaildCreateDir, &cDialogEvent), NULL, WM_FAILD_CREATE_DIR);
|
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnFaildCreateDir, &cDialogEvent), NULL, WM_FAILD_CREATE_DIR);
|
||||||
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnWaifu2xError, &cDialogEvent), NULL, WM_ON_WAIFU2X_ERROR);
|
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnWaifu2xError, &cDialogEvent), NULL, WM_ON_WAIFU2X_ERROR);
|
||||||
|
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnWaifu2xNoOverwrite, &cDialogEvent), NULL, WM_ON_WAIFU2X_NO_OVERWRITE);
|
||||||
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::WaitThreadExit, &cDialogEvent), NULL, WM_END_THREAD);
|
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::WaitThreadExit, &cDialogEvent), NULL, WM_END_THREAD);
|
||||||
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::Timer, &cDialogEvent), NULL, WM_TIMER);
|
cDialog.SetEventCallBack(SetClassFunc(DialogEvent::Timer, &cDialogEvent), NULL, WM_TIMER);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user