From 0ce4f7624f06c288191d9d92f9148ab05ff5c172 Mon Sep 17 00:00:00 2001 From: sonicfind <52436993+sonicfind@users.noreply.github.com> Date: Sun, 20 Sep 2020 00:13:09 -0500 Subject: [PATCH] GSdx-Capture: Abort capture if an invalid directory is given --- plugins/GSdx/GSCapture.cpp | 15 ++++++++++++--- plugins/GSdx/Window/GSCaptureDlg.cpp | 7 +++++++ plugins/GSdx/Window/GSCaptureDlg.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index 113227ff49..21495e72d2 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -420,9 +420,6 @@ std::wstring* GSCapture::BeginCapture(float fps, GSVector2i recommendedResolutio if (IDOK != dlg.DoModal()) return nullptr; - m_size.x = (dlg.m_width + 7) & ~7; - m_size.y = (dlg.m_height + 7) & ~7; - { int start = dlg.m_filename.length() - 4; if (start > 0) @@ -434,9 +431,21 @@ std::wstring* GSCapture::BeginCapture(float fps, GSVector2i recommendedResolutio } else dlg.m_filename += ".avi"; + + FILE* test = fopen(dlg.m_filename.c_str(), "w"); + if (test) + fclose(test); + else + { + dlg.InvalidFile(); + return nullptr; + } } + std::wstring fn{dlg.m_filename.begin(), dlg.m_filename.end()}; + m_size.x = (dlg.m_width + 7) & ~7; + m_size.y = (dlg.m_height + 7) & ~7; // HRESULT hr; diff --git a/plugins/GSdx/Window/GSCaptureDlg.cpp b/plugins/GSdx/Window/GSCaptureDlg.cpp index c5e7981b28..0b56c3e18a 100644 --- a/plugins/GSdx/Window/GSCaptureDlg.cpp +++ b/plugins/GSdx/Window/GSCaptureDlg.cpp @@ -35,6 +35,13 @@ #define EndEnumSysDev }}} +void GSCaptureDlg::InvalidFile() +{ + char tmp[512]; + sprintf_s(tmp, "GSdx couldn't open file for capturing: %s.\nCapture aborted.", m_filename.c_str()); + MessageBox(GetActiveWindow(), tmp, "GSdx System Message", MB_OK | MB_SETFOREGROUND); +} + GSCaptureDlg::GSCaptureDlg() : GSDialog(IDD_CAPTURE) { diff --git a/plugins/GSdx/Window/GSCaptureDlg.h b/plugins/GSdx/Window/GSCaptureDlg.h index 56a6d938e9..17a6ce43f7 100644 --- a/plugins/GSdx/Window/GSCaptureDlg.h +++ b/plugins/GSdx/Window/GSCaptureDlg.h @@ -46,6 +46,7 @@ protected: public: GSCaptureDlg(); + void InvalidFile(); int m_width; int m_height;