persistentstorage/sql/SRC/Server/SqlSrvUtil.cpp
branchRCL_3
changeset 12 6b6fd149daa2
parent 8 fa9941cf3867
child 23 26645d81f48d
equal deleted inserted replaced
11:211563e4b919 12:6b6fd149daa2
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   145 */
   145 */
   146 TBool UTF16ToUTF8(const TDesC& aIn, TDes8& aOut)
   146 TBool UTF16ToUTF8(const TDesC& aIn, TDes8& aOut)
   147 	{
   147 	{
   148 	__SQLASSERT(aIn.Length() <= KMaxFileName, ESqlPanicBadArgument);
   148 	__SQLASSERT(aIn.Length() <= KMaxFileName, ESqlPanicBadArgument);
   149 	__SQLASSERT(aOut.MaxLength() >= KMaxFileName, ESqlPanicBadArgument);
   149 	__SQLASSERT(aOut.MaxLength() >= KMaxFileName, ESqlPanicBadArgument);
   150 	if(aIn.Length() > KMaxFileName || aOut.MaxLength() < KMaxFileName)
       
   151 		{
       
   152 		return EFalse;	
       
   153 		}
       
   154 	TBuf16<KMaxFileName + 1> des;
   150 	TBuf16<KMaxFileName + 1> des;
   155 	des.Copy(aIn);
   151 	des.Copy(aIn);
   156 	des.Append(TChar(0));
   152 	des.Append(TChar(0));
   157 	TInt len = wcstombs((char*)aOut.Ptr(), (const wchar_t*)des.Ptr(), KMaxFileName);
   153 	TInt len = wcstombs((char*)aOut.Ptr(), (const wchar_t*)des.Ptr(), KMaxFileName);
   158 	//Check the file name length. If it is longer than KMaxFileName characters, then the file name is not valid.
   154 	//Check the file name length. If it is longer than KMaxFileName characters, then the file name is not valid.