1 /* |
1 /* |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-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". |
73 static std::wstring wstr; |
73 static std::wstring wstr; |
74 return Utf8ToUcs2(aStr,wstr); |
74 return Utf8ToUcs2(aStr,wstr); |
75 } |
75 } |
76 |
76 |
77 |
77 |
|
78 void ConvertToPlatformSpecificPath( TUint16* aIn, TUint32 len ) |
|
79 { |
|
80 while( len-- > 0 ) |
|
81 { |
|
82 if( *aIn == '\\' ) |
|
83 { |
|
84 *aIn = '/'; |
|
85 } |
|
86 aIn++; |
|
87 } |
|
88 } |
|
89 |
|
90 #ifdef __TOOLS2_LINUX__ |
|
91 void ConvertToForwardSlash( std::wstring& aIn) |
|
92 { |
|
93 std::wstring::size_type idx = 0; |
|
94 |
|
95 while( (idx = aIn.find(L"\\", idx)) != std::wstring::npos) |
|
96 { |
|
97 aIn.replace( idx, 1, KDirectorySeparator ); |
|
98 } |
|
99 } |
|
100 #endif |
|
101 |
|
102 |
78 void ConvertToLocalPath( std::wstring& aIn, const std::wstring& aDrivePath ) |
103 void ConvertToLocalPath( std::wstring& aIn, const std::wstring& aDrivePath ) |
79 { |
104 { |
80 std::wstring::size_type idx = 0; |
105 std::wstring::size_type idx = 0; |
81 while( (idx = aIn.find(L"\\\\", idx)) != std::wstring::npos) |
106 |
|
107 #ifndef __TOOLS2_LINUX__ |
|
108 while( (idx = aIn.find(L"//", idx)) != std::wstring::npos) |
82 { |
109 { |
83 aIn.replace( idx, 4, KDirectorySeparator ); |
110 aIn.replace( idx, 2, KDoubleSlashPathPrefix ); |
84 } |
111 } |
85 // |
112 |
86 idx = 0; |
113 idx = 0; |
|
114 |
87 while( (idx = aIn.find(L"/", idx)) != std::wstring::npos) |
115 while( (idx = aIn.find(L"/", idx)) != std::wstring::npos) |
88 { |
116 { |
89 aIn.replace( idx, 1, KDirectorySeparator ); |
117 aIn.replace( idx, 1, KDirectorySeparator ); |
90 } |
118 } |
91 |
119 #else |
|
120 |
|
121 idx = 0; |
|
122 |
|
123 while( (idx = aIn.find(L"\\\\", idx)) != std::wstring::npos) |
|
124 { |
|
125 aIn.replace( idx, 2, KDoubleSlashPathPrefix ); |
|
126 } |
|
127 |
|
128 idx = 0; |
|
129 |
|
130 while( (idx = aIn.find(L"\\", idx)) != std::wstring::npos) |
|
131 { |
|
132 aIn.replace( idx, 1, KDirectorySeparator ); |
|
133 } |
|
134 #endif |
92 // If the first two characters represent a drive specification |
135 // If the first two characters represent a drive specification |
93 // then replace them entirely with the value from the |
136 // then replace them entirely with the value from the |
94 // PC's path ('aDrivePath'). |
137 // PC's path ('aDrivePath'). |
95 // |
138 // |
96 // Otherwise, we'll just prepend the PC's path, leaving |
139 // Otherwise, we'll just prepend the PC's path, leaving |
97 // the data in aIn intact. |
140 // the data in aIn intact. |
98 const bool startsWithDrive = StringUtils::StartsWithDrive( aIn ); |
141 const bool startsWithDrive = StringUtils::StartsWithDrive( aIn ); |
99 if ( startsWithDrive ) |
142 if ( startsWithDrive ) |
100 { |
143 { |
101 aIn.replace(aIn.begin(), aIn.begin()+2, aDrivePath); |
144 aIn.replace(aIn.begin(), aIn.begin()+2, aDrivePath.c_str()); |
102 } |
145 } |
103 else |
146 else |
104 { |
147 { |
105 aIn.insert( 0, aDrivePath ); |
148 aIn.insert( 0, aDrivePath.c_str() ); |
106 } |
149 } |
107 } |
150 } |
108 |
|
109 |
151 |
110 struct TPair { |
152 struct TPair { |
111 TUint16 first; |
153 TUint16 first; |
112 TUint16 second; |
154 TUint16 second; |
113 }; |
155 }; |
1006 } |
1048 } |
1007 return aC; |
1049 return aC; |
1008 } |
1050 } |
1009 int FoldedCompare(const std::wstring& aLeft, const std::wstring& aRight) |
1051 int FoldedCompare(const std::wstring& aLeft, const std::wstring& aRight) |
1010 { |
1052 { |
1011 std::wstring::const_iterator l = aLeft.begin(); |
1053 std::wstring iLeft=aLeft.c_str(); |
1012 std::wstring::const_iterator r = aRight.begin(); |
1054 std::wstring iRight=aRight.c_str(); |
1013 std::wstring::const_iterator le = aLeft.end(); |
1055 |
1014 std::wstring::const_iterator re = aRight.end(); |
1056 #ifdef __TOOLS2_LINUX__ |
|
1057 std::wstring::size_type idx = 0; |
|
1058 |
|
1059 while( (idx = iLeft.find(L"\\", idx)) != std::wstring::npos) |
|
1060 { |
|
1061 iLeft.replace( idx, 1, KDirectorySeparator ); |
|
1062 } |
|
1063 #endif |
|
1064 |
|
1065 std::wstring::const_iterator l = iLeft.begin(); |
|
1066 std::wstring::const_iterator r = iRight.begin(); |
|
1067 std::wstring::const_iterator le = iLeft.end(); |
|
1068 std::wstring::const_iterator re = iRight.end(); |
1015 |
1069 |
1016 while (l != le && r != re) |
1070 while (l != le && r != re) |
1017 { |
1071 { |
1018 wchar_t lf = Fold(*l); |
1072 wchar_t lf = Fold(*l); |
1019 wchar_t rf = Fold(*r); |
1073 wchar_t rf = Fold(*r); |