secureswitools/swisistools/source/sisxlibrary/utility.cpp
branchRCL_3
changeset 24 5cc91383ab1e
parent 0 ba25891c3a9e
child 25 7333d7932ef7
equal deleted inserted replaced
23:cd189dac02f7 24:5cc91383ab1e
     1 /*
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    46 		(*iStream) << aString;
    46 		(*iStream) << aString;
    47 		}
    47 		}
    48 	}
    48 	}
    49 
    49 
    50 
    50 
    51 std::string wstring2string (const std::wstring& aWide)
    51 DllExport std::string wstring2string (const std::wstring& aWide)
    52 	{
    52 	{
    53 	int max = ConvertWideCharToMultiByte(aWide.c_str(),aWide.length(),0,0);
    53 	int max = ConvertWideCharToMultiByte(aWide.c_str(),aWide.length(),0,0);
    54 	std::string reply;
    54 	std::string reply;
    55 	if (max > 0 )
    55 	if (max > 0 )
    56 		{
    56 		{
    82 			}
    82 			}
    83 		catch (...)
    83 		catch (...)
    84 			{
    84 			{
    85 			}
    85 			}
    86 		delete [] buffer;
    86 		delete [] buffer;
    87 		}
    87 		}	
    88 	return reply;
    88 	return reply.c_str();
    89 	}
    89 	}
    90 
    90 
    91 void EnsureExtended (std::wstring& aName, const std::wstring& aDefaultExtension)
    91 void EnsureExtended (std::wstring& aName, const std::wstring& aDefaultExtension)
    92 	{
    92 	{
    93 	assert (! aName.empty ());
    93 	assert (! aName.empty ());
   372 	}
   372 	}
   373 
   373 
   374 
   374 
   375 std::wstring FixPathDelimiters( const std::wstring& aString )
   375 std::wstring FixPathDelimiters( const std::wstring& aString )
   376     {
   376     {
       
   377 
   377     std::wstring ret = aString;
   378     std::wstring ret = aString;
   378 	
       
   379     std::wstring::size_type idx = 0;
   379     std::wstring::size_type idx = 0;
   380     int len = 0;
   380     int len = 0;
   381 	while(len = FirstInvalidDirSeparatorSize(ret, idx))
   381 	while(len = FirstInvalidDirSeparatorSize(ret, idx))
   382         {
   382         {
   383 		ret.replace( idx, len, KSisDirectorySeparator );
   383 		if(idx == 0 && len == 2)
       
   384 			{
       
   385 			ret.replace( idx, len, KSisInitialNetworkPathSlashes );
       
   386 			}
       
   387 		else
       
   388 			{
       
   389 			ret.replace( idx, len, KSisDirectorySeparator );
       
   390 			}
   384         }
   391         }
   385     return ret;
   392     return ret.c_str();
   386     }
   393     }
   387 
   394 
   388 int GetFileType(std::wstring& aFileName)
   395 int GetFileType(std::wstring& aFileName)
   389 	{
   396 	{
   390     int len = ConvertWideCharToMultiByte(aFileName.c_str(), -1, NULL, 0);
   397     int len = ConvertWideCharToMultiByte(aFileName.c_str(), -1, NULL, 0);