|
1 // Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file converts a linux/tcl path to or from a windows path. |
|
15 // |
|
16 // |
|
17 |
|
18 /* |
|
19 * convert to a windows path. required because PIPS |
|
20 * is mostly posix but uses Windows paths and tcl uses unix paths internally (see FsJoinPath()) |
|
21 * |
|
22 * inspired by TclWinNoBackslash() |
|
23 * |
|
24 * July 30, 2007 |
|
25 */ |
|
26 |
|
27 #include "convertPathSlashes.h" |
|
28 |
|
29 /** |
|
30 * Switch the separator chars inside a given string. both pointers can point |
|
31 * to the same string or different strings. |
|
32 * |
|
33 * @param direction direction to convert to. |
|
34 * @param pTo pointer of string to be converted. |
|
35 * @param pFrom pointer to string to be converted from. |
|
36 * |
|
37 * @ret pTo pointer to last char+1 of converted buffer. |
|
38 */ |
|
39 char* tclSymbianPathSlashConversion(direction, pTo, pFrom) |
|
40 PathConversionDirection direction; // TO_TCL - '\\' to '/', TO_SYMBIAN - '/' to '\\' |
|
41 char *pTo; // string to be converted. |
|
42 const char *pFrom; // string to be converted. |
|
43 { |
|
44 char toChar; |
|
45 char fromChar; |
|
46 |
|
47 if (direction == TO_TCL) { |
|
48 fromChar = '\\'; |
|
49 toChar = '/'; |
|
50 } |
|
51 else { // TO_SYMBIAN |
|
52 fromChar = '/'; |
|
53 toChar = '\\'; |
|
54 } |
|
55 |
|
56 for (; *pFrom != '\0'; pTo++, pFrom++) { |
|
57 if (*pFrom == fromChar) { |
|
58 *pTo = toChar; |
|
59 } |
|
60 else { |
|
61 *pTo = *pFrom; |
|
62 } |
|
63 }//for |
|
64 |
|
65 return pTo; |
|
66 } |
|
67 |
|
68 /** |
|
69 * Copies the source path to the destination path and null |
|
70 * terminates the destination string. |
|
71 * |
|
72 * @param direction direction to convert to. |
|
73 * @param pTo pointer of string to be converted. |
|
74 * @param pFrom pointer to string to be converted from. |
|
75 */ |
|
76 // copy from fromStrPtr into a buffer supplied by toStrPtr. |
|
77 void tclCopySymbianPathSlashConversion(direction, toStrPtr, fromStrPtr) |
|
78 PathConversionDirection direction; // TO_TCL - '\\' to '/', TO_SYMBIAN - '/' to '\\' |
|
79 char *toStrPtr; // string to be converted. |
|
80 const char *fromStrPtr;// string to convert from. |
|
81 { |
|
82 char* pTo; |
|
83 const char* pFrom; |
|
84 |
|
85 |
|
86 pTo = toStrPtr; |
|
87 pFrom = fromStrPtr; |
|
88 pTo = tclSymbianPathSlashConversion(direction, pTo, pFrom); |
|
89 *pTo = '\0'; |
|
90 } |
|
91 |