From 0f2af9679c8f5669e533b35ceea29b79a599a529 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 29 May 2010 04:44:56 +0000 Subject: [PATCH] zeropad: Patch zeropad to use SetLogFolder. (modified from a patch by gregory) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3112 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zeropad/zeropad.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/zeropad/zeropad.cpp b/plugins/zeropad/zeropad.cpp index 1acfd90614..b509a5cb38 100644 --- a/plugins/zeropad/zeropad.cpp +++ b/plugins/zeropad/zeropad.cpp @@ -41,6 +41,7 @@ u16 status[2]; int pressure; static keyEvent s_event; string s_strIniPath = "inis"; +string s_strLogPath = "logs"; const u32 version = PS2E_PAD_VERSION; const u32 revision = 0; @@ -217,13 +218,28 @@ void initLogging() #ifdef PAD_LOG if (padLog == NULL) { - padLog = fopen("logs/padLog.txt", "w"); - if (padLog) setvbuf(padLog, NULL, _IONBF, 0); + const std::string LogFile(s_strLogPath + "/padLog.txt"); + padLog = fopen(LogFile.c_str(), "w"); + if (padLog == NULL) + SysMessage("Can't create log file %s\n", LogFile.c_str()); + else + setvbuf(padLog, NULL, _IONBF, 0); } PAD_LOG("PADinit\n"); #endif } +void CloseLogging() +{ +#ifdef PAD_LOG + if (padLog != NULL) + { + fclose(padLog); + padLog = NULL; + } +#endif +} + s32 CALLBACK PADinit(u32 flags) { initLogging(); @@ -273,6 +289,17 @@ void CALLBACK PADsetSettingsDir(const char* dir) // Get the path to the ini directory. s_strIniPath = (dir==NULL) ? "inis/" : dir; } + +void CALLBACK PADSetLogFolder(const char* dir) +{ + // Get the path to the log directory. + s_strLogPath = (dir==NULL) ? "logs/" : dir; + + // Reload the log file after updated the path + CloseLogging(); + initLogging(); +} + void CALLBACK PADclose() {