From 8eb630a6605fed621fd7acd5b0cafa4143149aa8 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Tue, 22 Jan 2013 16:56:01 +0000 Subject: - fixed r3219 - all HTTPServer files are read and created in ProfileDir\HTTPServer. You need to copy your files manually. git-svn-id: http://svn.miranda-ng.org/main/trunk@3232 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HTTPServer/src/main.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'plugins/HTTPServer/src/main.cpp') diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index 182c50ea31..91ac702a0d 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -331,19 +331,20 @@ bool bReadConfigurationFile() { bool bWriteConfigurationFile() { CLFileShareListAccess clCritSection; char szBuf[1000]; - TCHAR * temp = ""; strcpy(szBuf, szPluginPath); strcat(szBuf, szConfigFile); HANDLE hFile = CreateFile(szBuf, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to open or create file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to open or create file "), _T(szConfigFile)); MessageBox(NULL, temp , MSG_BOX_TITEL, MB_OK); return false; } DWORD dwBytesWriten = 0; if (! WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, NULL)) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to write xml header to file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml header to file "), _T(szConfigFile)); MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK); } else { CLFileShareNode * pclCur = pclFirstNode; @@ -356,7 +357,8 @@ bool bWriteConfigurationFile() { SplitIpAddress(pclCur->st.dwAllowedMask)); if (! WriteFile(hFile, szBuf, dwBytesToWrite, &dwBytesWriten, NULL)) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to write xml data to file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml data to file "), _T(szConfigFile)); MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK); break; } @@ -364,7 +366,8 @@ bool bWriteConfigurationFile() { } if (! WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWriten, NULL)) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to write xml tail to file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml tail to file "), _T(szConfigFile)); MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK); } } @@ -911,13 +914,18 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) { return 0; } - szPluginPath[0] = 0; - if (GetModuleFileName(hInstance, szPluginPath, sizeof(szPluginPath))) { - char *str2 = strrchr(szPluginPath, '\\'); - if (str2 != NULL) { - str2[1] = NULL; - } + if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath)) + { + MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK); + return 0; } + _tcscat(szPluginPath,_T("\\HTTPServer\\")); + if(CreateDirectoryTree(szPluginPath)) + { + MessageBox(NULL, _T("Failed to create HTTPServer directory."), MSG_BOX_TITEL, MB_OK); + return 0; + } + nPluginPathLen = strlen(szPluginPath); sLogFilePath = szPluginPath; -- cgit v1.2.3