--- a/secureswitools/swisistools/source/interpretsislib/stringutils.cpp Wed Sep 15 12:20:42 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/stringutils.cpp Wed Oct 13 14:40:19 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
@@ -30,7 +30,6 @@
#include "is_utils.h"
#include "logger.h"
#include "utility_interface.h"
-#include "util.h"
// Constants
const int KInterpretSISExpectedSIDLength = 8;
@@ -52,29 +51,14 @@
// then the function will return 0
int ret = 0;
int pos = 0;
- #ifndef __TOOLS2_LINUX__
- if((pos = aPath.find(L"//", aIndex)) != std::wstring::npos)
+ if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos)
{
- ret = 2;
+ ret = 1;
}
- #else
- if((pos = aPath.find(L"\\\\", aIndex)) != std::wstring::npos)
+ else if((pos = aPath.find(L"\\\\", aIndex)) != std::wstring::npos)
{
ret = 2;
}
- #endif
-
- #ifndef __TOOLS2_LINUX__
- else if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos)
- {
- ret = 1;
- }
- #else
- else if((pos = aPath.find(L"\\", aIndex)) != std::wstring::npos)
- {
- ret = 1;
- }
- #endif
aIndex = pos;
return ret;
}
@@ -89,9 +73,7 @@
int len = ConvertMultiByteToWideChar(src, -1, NULL, 0);
buf = new wchar_t[len+1];
len = ConvertMultiByteToWideChar(src, -1, buf, len);
-
- ret = std::wstring( buf ,len);
-
+ ret = std::wstring( buf );
delete[] buf;
//
std::wstring::size_type idx = 0;
@@ -100,7 +82,7 @@
ret.replace(idx, len, KDirectorySeparator);
}
//
- return ret.c_str();
+ return ret;
}
@@ -162,14 +144,6 @@
return ret;
}
-std::wstring StringUtils::ToLower( const std::wstring& aString )
- {
- std::wstring ret( aString );
- std::transform( ret.begin(), ret.end(), ret.begin(), tolower );
-
- return ret;
- }
-
bool StringUtils::IsLastCharacter( const std::wstring& aString, wchar_t aChar )
{
bool isLast = false;
@@ -190,19 +164,15 @@
//
if ( aText.length() >= 3 )
{
- const std::string prefix = ToUpper( wstring2string( aText.substr( 0, 3 ) ) );
+ const std::string prefix = ToUpper( Ucs2ToUtf8( aText.substr( 0, 3 ) ) );
//
const char drive = prefix[ 0 ];
const char colon = prefix[ 1 ];
const char backslash = prefix[ 2 ];
//
- #ifndef __TOOLS2_LINUX__
if ( colon == ':' && backslash == '\\' )
- #else
- if ( colon == ':' && (backslash == '/' || backslash == '\\'))
- #endif
{
- startsWithDrive = ( drive >= 'A' && drive <= 'Z' ) || (drive == '!') || (drive == '$') ;
+ startsWithDrive = ( drive >= 'A' && drive <= 'Z' ) || (drive == '!') ;
}
}
//
@@ -300,29 +270,6 @@
*/
bool StringUtils::WildcardCompare(const std::wstring& aWildCardFileName, const std::wstring& aFileName)
{
- #ifdef __TOOLS2_LINUX__
- // In case the incoming data is a DB entry then it will be having windows
- // specific paths due to the consistency of DB contents across WINDOWS
- // and LINUX. So, we need to convert them to LINUX paths and then compare.
-
- std::wstring::size_type idx = 0;
-
- while( (idx = aWildCardFileName.find(L"\\", idx)) != std::wstring::npos)
- {
- aWildCardFileName.replace( idx, 1, L"/" );
- }
-
- idx = 0;
-
- while( (idx = aFileName.find(L"\\", idx)) != std::wstring::npos)
- {
- aFileName.replace( idx, 1, L"/" );
- }
- #endif
-
- aWildCardFileName = StringUtils::ToLower(aWildCardFileName);
- aFileName = StringUtils::ToLower(aFileName);
-
std::wstring::const_iterator wildCurr = aWildCardFileName.begin();
std::wstring::const_iterator wildEnd = aWildCardFileName.end();
@@ -410,19 +357,7 @@
*/
std::wstring StringUtils::NameAndExt( const std::wstring& aFile )
{
-#ifndef __TOOLS2_LINUX__
int pos = aFile.find_last_of(L"\\");
-#else
- // We should also check for backward slash since the caller could be
- // passing a string containing a windows-specific paths within LINUX.
- //
- // One instance being - an SCR database entry under LINUX, which has
- // the windows specific paths of the installed files to maintain
- // consistency across WINDOWS and LINUX platforms.
-
- int pos = aFile.find_last_of(L"/");
- pos = pos == std::wstring::npos ? aFile.find_last_of(L"\\") : pos;
-#endif
if (pos == std::wstring::npos)
{
return L"";
@@ -447,11 +382,7 @@
*/
std::wstring StringUtils::DriveAndPath( const std::wstring& aFile )
{
-#ifndef __TOOLS2_LINUX__
- int pos = aFile.find_last_of(L"\\");
-#else
- int pos = aFile.find_last_of(L"/");
-#endif
+ int pos = aFile.find_last_of(L"\\");
if (pos == std::wstring::npos)
{
return L"";
@@ -474,13 +405,8 @@
*/
std::wstring StringUtils::Path( const std::wstring& aFile )
{
-#ifndef __TOOLS2_LINUX__
- int firstPos = aFile.find_first_of(L"\\");
- int lastPos = aFile.find_last_of(L"\\");
-#else
- int firstPos = aFile.find_first_of(L"/");
- int lastPos = aFile.find_last_of(L"/");
-#endif
+ int firstPos = aFile.find_first_of(L"\\");
+ int lastPos = aFile.find_last_of(L"\\");
if (lastPos >= firstPos)
{
@@ -502,12 +428,7 @@
*/
std::wstring StringUtils::Name( const std::wstring& aFile )
{
-#ifndef __TOOLS2_LINUX__
int startPos = aFile.find_last_of(L"\\");
-#else
- int startPos = aFile.find_last_of(L"/");
-#endif
-
int endPos = aFile.find_last_of(L".");
if (endPos > startPos)