Example #1
0
bool CWINFileSMB::Exists(const CURL& url)
{
    CStdString strFile = GetLocal(url);
    URIUtils::RemoveSlashAtEnd(strFile);
    CStdStringW strWFile;
    g_charsetConverter.utf8ToW(strFile, strWFile, false);
    DWORD attributes = GetFileAttributesW(strWFile.c_str());
    if(attributes != INVALID_FILE_ATTRIBUTES)
        return true;

    DWORD err = GetLastError();
    if(err != ERROR_ACCESS_DENIED)
        return false;

    XFILE::CWINSMBDirectory smb;
    if(smb.ConnectToShare(url) == false)
        return false;

    attributes = GetFileAttributesW(strWFile.c_str());

    if(attributes == INVALID_FILE_ATTRIBUTES)
        return false;

    return true;
}
Example #2
0
//*********************************************************************************************
bool CWINFileSMB::Open(const CURL& url)
{
    CStdString strFile = GetLocal(url);

    CStdStringW strWFile;
    g_charsetConverter.utf8ToW(strFile, strWFile, false);
    m_hFile.attach(CreateFileW(strWFile.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL));

    if (!m_hFile.isValid())
    {
        if(GetLastError() == ERROR_FILE_NOT_FOUND)
            return false;

        XFILE::CWINSMBDirectory smb;
        smb.ConnectToShare(url);
        m_hFile.attach(CreateFileW(strWFile.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL));
        if (!m_hFile.isValid())
        {
            CLog::Log(LOGERROR,"CWINFileSMB: Unable to open file %s Error: %d", strFile.c_str(), GetLastError());
            return false;
        }
    }

    m_i64FilePos = 0;
    Seek(0, SEEK_SET);

    return true;
}
Example #3
0
//*********************************************************************************************
bool CWINFileSMB::OpenForWrite(const CURL& url, bool bOverWrite)
{
    CStdString strPath = GetLocal(url);

    CStdStringW strWPath;
    g_charsetConverter.utf8ToW(strPath, strWPath, false);
    m_hFile.attach(CreateFileW(strWPath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, bOverWrite ? CREATE_ALWAYS : OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));

    if (!m_hFile.isValid())
    {
        if(GetLastError() == ERROR_FILE_NOT_FOUND)
            return false;

        XFILE::CWINSMBDirectory smb;
        smb.ConnectToShare(url);
        m_hFile.attach(CreateFileW(strWPath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, bOverWrite ? CREATE_ALWAYS : OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
        if (!m_hFile.isValid())
        {
            CLog::Log(LOGERROR,"CWINFileSMB: Unable to open file for writing '%s' Error '%d%",strPath.c_str(), GetLastError());
            return false;
        }
    }

    m_i64FilePos = 0;
    Seek(0, SEEK_SET);

    return true;
}
Example #4
0
void DominoDocArtifact::Download()
{
   DominoDoc::IDocumentPtr spDocument = GetDocument();   
   CStdStringW workingFileName = CTempFileManager::GetTempFileName();
   spDocument->GetContents(workingFileName.c_str());
   m_workingFileName = workingFileName.c_str();

   Log(_T("The working file [%S] was downloaded from the Domino.Doc library [%S] as document [%S]"), m_workingFileName.c_str(), m_libraryUrl.c_str(), m_documentId.c_str());
}
Example #5
0
bool CWINFileSMB::Rename(const CURI& url, const CURI& urlnew)
{
  CStdString strFile=GetLocal(url);
  CStdString strNewFile=GetLocal(urlnew);

  CStdStringW strWFile;
  CStdStringW strWNewFile;
  g_charsetConverter.utf8ToW(strFile, strWFile, false);
  g_charsetConverter.utf8ToW(strNewFile, strWNewFile, false);
  return ::MoveFileW(strWFile.c_str(), strWNewFile.c_str()) ? true : false;
}
Example #6
0
bool CHDFile::Rename(const CURL& url, const CURL& urlnew)
{
    CStdString strFile=GetLocal(url);
    CStdString strNewFile=GetLocal(urlnew);

#ifdef _WIN32
    CStdStringW strWFile;
    CStdStringW strWNewFile;
    g_charsetConverter.utf8ToW(strFile, strWFile, false);
    g_charsetConverter.utf8ToW(strNewFile, strWNewFile, false);
    return ::MoveFileW(strWFile.c_str(), strWNewFile.c_str()) ? true : false;
#else
    return ::MoveFile(strFile.c_str(), strNewFile.c_str()) ? true : false;
#endif
}
Example #7
0
void CCharsetConverter::utf16BEtoUTF8(const CStdStringW& strSource, CStdStringA &strDest)
{
  if (m_iconvUtf16BEtoUtf8 == (iconv_t) - 1)
    m_iconvUtf16BEtoUtf8 = iconv_open("UTF-8", "UTF-16BE");

  if (m_iconvUtf16BEtoUtf8 != (iconv_t) - 1)
  {
    size_t inBytes  = (strSource.length() + 1) * sizeof(wchar_t);
    size_t outBytes = (strSource.length() + 1) * 4;
    const char *src = (const char*) strSource.c_str();
    char       *dst = strDest.GetBuffer(outBytes);

    if (iconv_const(m_iconvUtf16BEtoUtf8, &src, &inBytes, &dst, &outBytes))
    {
      CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
      strDest.ReleaseBuffer();
      strDest = strSource;
      return;
    }

    if (iconv(m_iconvUtf16BEtoUtf8, NULL, NULL, &dst, &outBytes))
    {
      CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
      strDest.ReleaseBuffer();
      strDest = strSource;
      return;
    }
    strDest.ReleaseBuffer();
  }
}
PerformanceMonitor::PerformanceMonitor(const wchar_t* function) :
	m_function(function)	
{	
	try
	{
		if(PerformanceMonitor::m_timer == PerformanceMonitor::UnknownTimer)
		{			
			DetermineTimer();							
			PerformanceMonitor::m_enableLogging = IsLoggingSystemEnabled();
		}

		if(!PerformanceMonitor::m_enableLogging)
			return;

		if(PerformanceMonitor::m_timer == PerformanceMonitor::HighResolutionTimer)
				QueryPerformanceCounter(&m_start);
		else
			m_startClock = clock();

		CStdStringW sFunction;
		sFunction.Format(_T("Starting %s"), m_function.c_str());
		LOG_WS_INFO(sFunction.c_str());		
	}
	catch(...)
	{
	}
}
Example #9
0
extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
{
  char* p = strdup(lpFileName);
  CORRECT_SEP_STR(p);

  // change default \\*.* into \\* which the xbox is using
  char* e = strrchr(p, '.');
  if (e != NULL && strlen(e) > 1 && e[1] == '*')
  {
    e[0] = '\0';
  }

#ifdef TARGET_WINDOWS
  struct _WIN32_FIND_DATAW FindFileDataW;
  CStdStringW strwfile;
  g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(p), strwfile, false);
  HANDLE res = FindFirstFileW(strwfile.c_str(), &FindFileDataW);
  if (res != INVALID_HANDLE_VALUE)
    to_WIN32_FIND_DATA(&FindFileDataW, lpFindFileData);
#else
  HANDLE res = FindFirstFile(CSpecialProtocol::TranslatePath(p).c_str(), lpFindFileData);
#endif
  free(p);
  return res;
}
Example #10
0
bool Win32DllLoader::Load()
{
  if (m_dllHandle != NULL)
    return true;

  CStdString strFileName = GetFileName();
  CLog::Log(LOGDEBUG, "%s(%s)\n", __FUNCTION__, strFileName.c_str());

  CStdStringW strDllW;
  g_charsetConverter.utf8ToW(_P(strFileName), strDllW);
  m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  if (!m_dllHandle)
  {
    CLog::Log(LOGERROR, "%s: Unable to load %s (%d)", __FUNCTION__, strFileName.c_str(), GetLastError());
    return false;
  }

  // handle functions that the dll imports
  if (NeedsHooking(strFileName.c_str()))
    OverrideImports(strFileName);
  else
    bIsSystemDll = true;

  return true;
}
_bstr_t GetString(const OcText& value)
{
   if(!value.getBuffer() || (1 > value.getCharacterCount()))
      return _T("");
   
   switch(value.getCharacterEncoding())
   {
      case ENCODING_NONE:
      {
         CStdString val((const TCHAR*)value.getBuffer());
         val.Trim();
         val.ReleaseBuffer();
         return val.c_str();
      }   
      case ENCODING_UTF16:
      {
         CStdStringW wideVal((const wchar_t*)value.getBuffer());
         wideVal.Trim();
         wideVal.ReleaseBuffer();
         return wideVal.c_str();
      }
      default:
      {
         CStdStringA multiByteVal((LPSTR)value.getBuffer());
         multiByteVal.ReleaseBuffer();
         CStdStringW wideVal = MultiByteSupport::ACPToWide(multiByteVal);
         return wideVal.c_str();
      }
   }
}
Example #12
0
HRESULT DMSHelper::DeleteDocument(CStdStringW sDocID)
{
	LOG_WS_FUNCTION_SCOPE_MSG(sDocID);

	HRESULT hr = GetDocProvProxy()->DeleteDocument(sDocID.c_str());
	return hr;
}
Example #13
0
HRESULT DMSHelper::GetLFSSaveInfo(long lHWnd, const CStdStringW& sFormatString, long lFlags, long* plFormatIndex, WSDocNonCom& docInfo)
{
	LOG_WS_FUNCTION_SCOPE_MSG(docInfo.GetDocId());

	HRESULT  hr = E_FAIL;
	WSDOCUMENTPROVIDERLib::tagWSDOCUMENT wsDocument;
	docInfo.InitializeWSDOCUMENT((WSDOCUMENT*) &wsDocument);

	hr = GetDocProvProxy()->GetLFSSaveInfo(lHWnd, _bstr_t(sFormatString.c_str()), lFlags, plFormatIndex, &wsDocument);
	
	if (SUCCEEDED(hr))
	{
		docInfo = WSDocNonCom((WSDOCUMENT*)&wsDocument);
	}
	else
	{
		CStdString sError;
		sError.Format(_T("hr = %x"), hr);
		LOG_WS_ERROR(sError.c_str());
	}
	// this gets used as a temp file path in many places so we need to _tremove illegal characters
	CStdString sDescription = docInfo.GetDescription();
	Gen::CFilePath::ReplaceIllegalCharsInFilePath(sDescription);
	docInfo.SetDescription(sDescription);
	WSDocCleaner::CleanWSDoc(wsDocument);
	return hr;
}
Example #14
0
bool Win32DllLoader::NeedsHooking(const char *dllName)
{
  LibraryLoader *loader = DllLoaderContainer::GetModule(dllName);
  if (loader)
  {
    // may have hooked this already (we can have repeats in the import table)
    for (unsigned int i = 0; i < m_referencedDlls.size(); i++)
    {
      if (loader->GetHModule() == m_referencedDlls[i])
        return false;
    }
  }
  CStdStringW strdllNameW;
  g_charsetConverter.utf8ToW(_P(dllName), strdllNameW, false);
  HMODULE hModule = GetModuleHandleW(strdllNameW.c_str());
  wchar_t filepathW[MAX_PATH];
  GetModuleFileNameW(hModule, filepathW, MAX_PATH);
  CStdString dllPath;
  g_charsetConverter.wToUTF8(filepathW, dllPath);

  // compare this filepath with some special directories
  CStdString xbmcPath = _P("special://xbmc");
  CStdString homePath = _P("special://home");
  CStdString tempPath = _P("special://temp");
  return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.GetLength()) == 0) ||
    (strncmp(homePath.c_str(), dllPath.c_str(), homePath.GetLength()) == 0) ||
    (strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.GetLength()) == 0));
}
Example #15
0
bool Win32DllLoader::Load()
{
  if (m_dllHandle != NULL)
    return true;

  CStdString strFileName = GetFileName();

  CStdStringW strDllW;
  g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strFileName), strDllW);
  m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  if (!m_dllHandle)
  {
    LPVOID lpMsgBuf;
    DWORD dw = GetLastError(); 

    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, 0, (LPTSTR) &lpMsgBuf, 0, NULL );
    CLog::Log(LOGERROR, "%s: Failed to load %s with error %d:%s", __FUNCTION__, CSpecialProtocol::TranslatePath(strFileName).c_str(), dw, lpMsgBuf);
    LocalFree(lpMsgBuf);
    return false;
  }

  // handle functions that the dll imports
  if (NeedsHooking(strFileName.c_str()))
    OverrideImports(strFileName);
  else
    bIsSystemDll = true;

  return true;
}
Example #16
0
bool CWINFileSMB::Delete(const CURI& url)
{
  CStdString strFile=GetLocal(url);

  CStdStringW strWFile;
  g_charsetConverter.utf8ToW(strFile, strWFile, false);
  return ::DeleteFileW(strWFile.c_str()) ? true : false;
}
Example #17
0
int CWINFileSMB::Stat(const CURI& url, struct __stat64* buffer)
{
  CStdString strFile = GetLocal(url);

  CStdStringW strWFile;
  g_charsetConverter.utf8ToW(strFile, strWFile, false);
  return _wstat64(strWFile.c_str(), buffer);
}
Example #18
0
bool CWINFileSMB::SetHidden(const CURL &url, bool hidden)
{
    CStdStringW path;
    g_charsetConverter.utf8ToW(GetLocal(url), path, false);
    DWORD attributes = hidden ? FILE_ATTRIBUTE_HIDDEN : FILE_ATTRIBUTE_NORMAL;
    if (SetFileAttributesW(path.c_str(), attributes))
        return true;
    return false;
}
Example #19
0
void CHTMLUtil::ConvertHTMLToW(const CStdStringW& strHTML, CStdStringW& strStripped)
{
  if (strHTML.size() == 0)
  {
    strStripped.Empty();
    return ;
  }
  int iPos = 0;
  strStripped = strHTML;
  while (mappings[iPos].html)
  {
    strStripped.Replace(mappings[iPos].html,CStdStringW(1, mappings[iPos].w));
    iPos++;
  }

  iPos = strStripped.Find(L"&#");
  while (iPos > 0 && iPos < (int)strStripped.size()-4)
  {
    int iStart = iPos + 1;
    iPos += 2;
    CStdStringW num;
    int base = 10;
    if (strStripped[iPos+1] == L'x')
    {
      base = 16;
      iPos++;
    }

    int i=iPos;
    while ( iPos < (int)strStripped.size() && 
           (base==16?iswxdigit(strStripped[iPos]):iswdigit(strStripped[iPos])))
      iPos++; 

    num = strStripped.Mid(i,iPos-i);
    wchar_t val = (wchar_t)wcstol(num.c_str(),NULL,base);
    if (base == 10)
      num.Format(L"&#%ls;",num.c_str());
    else
      num.Format(L"&#x%ls;",num.c_str());

    strStripped.Replace(num,CStdStringW(1,val));
    iPos = strStripped.Find(L"&#", iStart);
  }
}
Example #20
0
bool CWINFileSMB::Exists(const CURI& url)
{
  struct __stat64 buffer;
  if(url.GetFileName() == url.GetShareName())
    return false;
  CStdString strFile = GetLocal(url);
  CStdStringW strWFile;
  g_charsetConverter.utf8ToW(strFile, strWFile, false);
  return (_wstat64(strWFile.c_str(), &buffer)==0);
}
Example #21
0
//*********************************************************************************************
bool CWINFileSMB::Open(const CURI& url)
{
  CStdString strFile = GetLocal(url);

  CStdStringW strWFile;
  g_charsetConverter.utf8ToW(strFile, strWFile, false);
  m_hFile.attach(CreateFileW(strWFile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL));

  if (!m_hFile.isValid())
  {
    CLog::Log(LOGERROR,"CWINFileSMB: Unable to open file '%s' Error '%d%",strWFile.c_str(), GetLastError());
    return false;
  }

  m_i64FilePos = 0;
  Seek(0, SEEK_SET);

  return true;
}
Example #22
0
int CWINFileSMB::Stat(const CURL& url, struct __stat64* buffer)
{
    CStdString strFile = GetLocal(url);
    /* _wstat64 calls FindFirstFileEx. According to MSDN, the path should not end in a trailing backslash.
      Remove it before calling _wstat64 */
    if (strFile.length() > 3 && URIUtils::HasSlashAtEnd(strFile))
        URIUtils::RemoveSlashAtEnd(strFile);
    CStdStringW strWFile;
    g_charsetConverter.utf8ToW(strFile, strWFile, false);
    if(_wstat64(strWFile.c_str(), buffer) == 0)
        return 0;

    if(errno == ENOENT)
        return -1;

    XFILE::CWINSMBDirectory smb;
    if(smb.ConnectToShare(url) == false)
        return -1;

    return _wstat64(strWFile.c_str(), buffer);
}
Example #23
0
bool CHDFile::Delete(const CURL& url)
{
    CStdString strFile=GetLocal(url);

#ifdef _WIN32
    CStdStringW strWFile;
    g_charsetConverter.utf8ToW(strFile, strWFile, false);
    return ::DeleteFileW(strWFile.c_str()) ? true : false;
#else
    return ::DeleteFile(strFile.c_str()) ? true : false;
#endif
}
Example #24
0
void CWIN32Util::ExtendDllPath()
{
  CStdStringW strEnvW;
  CStdStringArray vecEnv;
  WCHAR wctemp[32768];
  if(GetEnvironmentVariableW(L"PATH",wctemp,32767) != 0)
    strEnvW = wctemp;

  StringUtils::SplitString(DLL_ENV_PATH, ";", vecEnv);
  for (int i=0; i<(int)vecEnv.size(); ++i)
  {
    CStdStringW strFileW;
    g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(vecEnv[i]), strFileW, false);
    strEnvW.append(L";" + strFileW);
  }
  if(SetEnvironmentVariableW(L"PATH",strEnvW.c_str())!=0)
    CLog::Log(LOGDEBUG,"Setting system env PATH to %S",strEnvW.c_str());
  else
    CLog::Log(LOGDEBUG,"Can't set system env PATH to %S",strEnvW.c_str());

}
Example #25
0
	void CFilename::SplitPath(const CStdStringW& path)
	{
		_wsplitpath(path.c_str(),
			drive.GetBuffer(MAX_PATH),
			dir.GetBuffer(MAX_PATH),
			fname.GetBuffer(MAX_PATH),
			ext.GetBuffer(MAX_PATH));
		drive.ReleaseBuffer();
		dir.ReleaseBuffer();
		fname.ReleaseBuffer();
		ext.ReleaseBuffer();
	}
Example #26
0
PyObject* XBMC_GetLocalizedString(PyObject *self, PyObject *args)
{
    int iString;
    if (!PyArg_ParseTuple(args, "i", &iString)) return NULL;

    CStdStringW unicodeLabel;
    if (iString >= 30000 && iString <= 30999)
        g_charsetConverter.utf8ToW(g_localizeStringsTemp.Get(iString), unicodeLabel);
    else
        g_charsetConverter.utf8ToW(g_localizeStrings.Get(iString), unicodeLabel);

    return Py_BuildValue("u", unicodeLabel.c_str());
}
Example #27
0
void CCharsetConverter::ucs2CharsetToStringCharset(const CStdStringW& strSource, CStdStringA& strDest, bool swap)
{
  if (m_iconvUcs2CharsetToStringCharset == (iconv_t) - 1)
  {
    CStdString strCharset=g_langInfo.GetGuiCharSet();
    m_iconvUcs2CharsetToStringCharset = iconv_open(strCharset.c_str(), "UTF-16LE");
  }

  if (m_iconvUcs2CharsetToStringCharset != (iconv_t) - 1)
  {
    CStdStringW strCopy = strSource;
    size_t inBytes  = (strCopy.length() + 1) * sizeof(wchar_t);
    size_t outBytes = (strCopy.length() + 1) * 4;
    const char *src = (const char*)strCopy.c_str();
    char       *dst = strDest.GetBuffer(inBytes);

    if (swap)
    {
      char* s = (char*) src;

      while (*s || *(s + 1))
      {
        char c = *s;
        *s = *(s + 1);
        *(s + 1) = c;

        s++;
        s++;
      }
    }

    if (iconv_const(m_iconvUcs2CharsetToStringCharset, &src, &inBytes, &dst, &outBytes) == (size_t)-1)
    {
      CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
      strDest.ReleaseBuffer();
      strDest = strSource;
      return;
    }

    if (iconv_const(m_iconvUcs2CharsetToStringCharset, NULL, NULL, &dst, &outBytes) == (size_t)-1)
    {
      CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
      strDest.ReleaseBuffer();
      strDest = strSource;
      return;
    }

    strDest.ReleaseBuffer();
  }
}
Example #28
0
static void to_WIN32_FIND_DATAW(LPWIN32_FIND_DATA data, LPWIN32_FIND_DATAW wdata)
{
  CStdStringW strwname;
  g_charsetConverter.utf8ToW(data->cFileName, strwname, false);
  size_t size = sizeof(wdata->cFileName) / sizeof(wchar_t);
  wcsncpy(wdata->cFileName, strwname.c_str(), size);
  if (size)
    wdata->cFileName[size - 1] = '\0';

  g_charsetConverter.utf8ToW(data->cAlternateFileName, strwname, false);
  size = sizeof(wdata->cAlternateFileName) / sizeof(wchar_t);
  wcsncpy(wdata->cAlternateFileName, strwname.c_str(), size);
  if (size)
    data->cAlternateFileName[size - 1] = '\0';

  wdata->dwFileAttributes = data->dwFileAttributes;
  wdata->ftCreationTime = data->ftCreationTime;
  wdata->ftLastAccessTime = data->ftLastAccessTime;
  wdata->ftLastWriteTime = data->ftLastWriteTime;
  wdata->nFileSizeHigh = data->nFileSizeHigh;
  wdata->nFileSizeLow = data->nFileSizeLow;
  wdata->dwReserved0 = data->dwReserved0;
  wdata->dwReserved1 = data->dwReserved1;
}
Example #29
0
PerformanceMonitor::~PerformanceMonitor(void)
{
	try
	{
		if(!PerformanceMonitor::m_enableLogging)
			return;

		double time = 0.0;		
		if(PerformanceMonitor::m_timer == PerformanceMonitor::HighResolutionTimer)
		{
			QueryPerformanceCounter(&m_end);
			LARGE_INTEGER frequency = m_ticksPerSecond;
			unsigned int high32 = m_end.HighPart - m_start.HighPart;
			DWORD reduceMagnitude = 0;
			while(high32)
			{
				high32 >>= 1;
				reduceMagnitude++;
			}

			INT_PTR overheadTicks = m_numberOfTicksUsedForOverhead;
			if(reduceMagnitude || m_adjustPerformanceFrequency)
			{
				if(m_adjustPerformanceFrequency > reduceMagnitude)
					reduceMagnitude = m_adjustPerformanceFrequency;
				m_start.QuadPart = Int64ShrlMod32(m_start.QuadPart, reduceMagnitude);
				m_end.QuadPart = Int64ShrlMod32(m_end.QuadPart, reduceMagnitude);
				frequency.QuadPart = Int64ShrlMod32(frequency.QuadPart, reduceMagnitude);
				overheadTicks >>= reduceMagnitude;
			}

			if(frequency.LowPart == 0)
				time = 0.0;
			else
				time = ((double)(m_end.LowPart - m_start.LowPart - overheadTicks))/frequency.LowPart;			
		}
		else
		{			
			m_endClock = clock();
			time = ((double)(m_endClock - m_startClock))/CLOCKS_PER_SEC;
		}

		CStdStringW sFunction;
		sFunction.Format(_T("%s took %f seconds"), m_function.c_str(), time);
		LOG_WS_INFO(sFunction.c_str());		
	}
Example #30
0
void CLog::OutputDebugString(const std::string& line)
{
#if defined(_DEBUG) || defined(PROFILE)
#if defined(TARGET_WINDOWS)
  // we can't use charsetconverter here as it's initialized later than CLog and deinitialized early
  int bufSize = MultiByteToWideChar(CP_UTF8, 0, line.c_str(), -1, NULL, 0);
  CStdStringW wstr (L"", bufSize);
  if ( MultiByteToWideChar(CP_UTF8, 0, line.c_str(), -1, wstr.GetBuf(bufSize), bufSize) == bufSize )
  {
    wstr.RelBuf();
    ::OutputDebugStringW(wstr.c_str());
  }
  else
#endif // TARGET_WINDOWS
    ::OutputDebugString(line.c_str());
  ::OutputDebugString("\n");
#endif
}