コード例 #1
0
ファイル: XMLUtils.cpp プロジェクト: Inferno1977/xbmc
/*!
  Returns true if the encoding of the document is other then UTF-8.
  /param strEncoding Returns the encoding of the document. Empty if UTF-8
*/
bool XMLUtils::GetEncoding(const CXBMCTinyXML* pDoc, CStdString& strEncoding)
{
  const TiXmlNode* pNode=NULL;
  while ((pNode=pDoc->IterateChildren(pNode)) && pNode->Type()!=TiXmlNode::TINYXML_DECLARATION) {}
  if (!pNode) return false;
  const TiXmlDeclaration* pDecl=pNode->ToDeclaration();
  if (!pDecl) return false;
  strEncoding=pDecl->Encoding();
  if (strEncoding.Equals("UTF-8") || strEncoding.Equals("UTF8")) strEncoding.Empty();
  strEncoding.MakeUpper();
  return !strEncoding.IsEmpty(); // Other encoding then UTF8?
}
コード例 #2
0
ファイル: Scrobbler.cpp プロジェクト: AICIDNN/lastfm-desktop
/*##############################################
##
## Module		: CScrobbler
## Function		: SupportedFileType
## Description	: Checks that the file type is valid 
##                for sending to the server
##
## Author(s)	: Spib
##
## Parameters	: strPath - full file path
## Return		: TRUE if file is OK
##
##############################################*/
BOOL CScrobbler::SupportedFileType(CStdString strPath)
{
	BOOL		bRet = TRUE;
	CStdString	strTemp;
	CStdString	strReason;
	int			nPos = 0;

	strPath.MakeUpper();

	strReason = "Unknown";

	if(!strPath.IsEmpty() && (strPath.GetLength() > 3))
	{
		strTemp = strPath.Left(7);
		if((strTemp == "HTTP://") && !m_bAllowHttpStreams)
		{
			bRet = FALSE;
			strReason = "Cannot submit HTTP streams";
            PRINTF(DEBUG_INFO, "CScrobbler::SupportedFileType",
                "File '%s' not supported: %s", strPath.c_str(), strReason.c_str());
			return bRet;
		}
		strTemp = strPath.Left(6);
		if((strTemp == "MMS://") && !m_bAllowHttpStreams)
		{
			bRet = FALSE;
			strReason = "Cannot submit MMS streams";
            PRINTF(DEBUG_INFO, "CScrobbler::SupportedFileType",
                "File '%s' not supported: %s", strPath.c_str(), strReason.c_str());
			return bRet;
		}
		// Is this a file?
		if (strTemp.Mid(1,2) == ":\\" ||
		    strTemp.Mid(0,2) == "\\\\")
		{
			nPos = strPath.ReverseFind('.');

			if(nPos > 0)
			{
				strTemp = strPath.Mid(nPos+1);
		
				if ((strTemp == "NSV") || 
				    (strTemp == "AVI") ||
    				(strTemp == "M2V") ||
	    			(strTemp == "ASF") ||
		    		(strTemp == "WMV") ||
			    	(strTemp == "MPG") ||
				    (strTemp == "MPEG"))
				{
					strReason = "Cannot submit Video files";
					bRet = FALSE;
                    PRINTF(DEBUG_INFO, "CScrobbler::SupportedFileType",
                        "File '%s' not supported: %s", strPath.c_str(), strReason.c_str());
                    return bRet;
				}
			}

		}
	}

	return bRet;	
}