diff options
author | wiso <wiso@svn> | 2009-12-21 20:50:17 +0000 |
---|---|---|
committer | wiso <wiso@svn> | 2009-12-21 20:50:17 +0000 |
commit | c65822836892999c0f95f23f93ab54950c948d93 (patch) | |
tree | ae8b0771f1cd49711b91ea4ad5cc1bbdcca6568f | |
parent | 7a79b6a7d3dfa85bc9bbb8aaa058483c158cd0fd (diff) |
[WIN32] fixed logfile writing.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@25945 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/utils/log.cpp | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/xbmc/utils/log.cpp b/xbmc/utils/log.cpp index 1bda09616f..8bee5b472c 100644 --- a/xbmc/utils/log.cpp +++ b/xbmc/utils/log.cpp @@ -23,6 +23,7 @@ #include "log.h" #ifndef _LINUX #include <share.h> +#include "CharsetConverter.h" #endif #include "CriticalSection.h" #include "SingleLock.h" @@ -138,15 +139,29 @@ void CLog::Log(int loglevel, const char *format, ... ) bool CLog::Init(const char* path) { -#ifdef _WIN32 - return InitW(path); -#endif - CSingleLock waitLock(critSec); if (!m_file) { // g_stSettings.m_logFolder is initialized in the CSettings constructor // and changed in CApplication::Create() +#ifdef _WIN32 + CStdStringW pathW; + g_charsetConverter.utf8ToW(path, pathW, false); + CStdStringW strLogFile, strLogFileOld; + + strLogFile.Format(L"%sxbmc.log", pathW); + strLogFileOld.Format(L"%sxbmc.old.log", pathW); + + struct __stat64 info; + if (_wstat64(strLogFileOld.c_str(),&info) == 0 && + !::DeleteFileW(strLogFileOld.c_str())) + return false; + if (_wstat64(strLogFile.c_str(),&info) == 0 && + !::MoveFileW(strLogFile.c_str(),strLogFileOld.c_str())) + return false; + + m_file = _wfopen(strLogFile.c_str(),L"wb"); +#else CStdString strLogFile, strLogFileOld; strLogFile.Format("%sxbmc.log", path); @@ -161,34 +176,8 @@ bool CLog::Init(const char* path) return false; m_file = fopen(strLogFile.c_str(),"wb"); +#endif } - - return m_file != NULL; -} - -bool CLog::InitW(const char* path) -{ - CSingleLock waitLock(critSec); - if (!m_file) - { - CStdStringW pathW; - g_charsetConverter.utf8ToW(path, pathW, false); - CStdStringW strLogFile, strLogFileOld; - - strLogFile.Format("%sxbmc.log", pathW); - strLogFileOld.Format("%sxbmc.old.log", pathW); - - struct stat64 info; - if (_wstat64(strLogFileOld.c_str(),&info) == 0 && - !::DeleteFileW(strLogFileOld.c_str())) - return false; - if (_wstat64(strLogFile.c_str(),&info) == 0 && - !::MoveFileW(strLogFile.c_str(),strLogFileOld.c_str())) - return false; - - m_file = _wfopen(strLogFile.c_str(),"wb"); - } - return m_file != NULL; } |