|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.IO; |
|
19 using System.Collections.Generic; |
|
20 |
|
21 namespace SymbolLib.CodeSegDef |
|
22 { |
|
23 public class CodeSegResolverEntry |
|
24 { |
|
25 #region Enumerations |
|
26 public enum TBuildType |
|
27 { |
|
28 EReleaseTypeRelease = 0, |
|
29 EReleaseTypeDebug |
|
30 } |
|
31 |
|
32 public enum TSourceType |
|
33 { |
|
34 ESourceNotDefined = 0, |
|
35 ESourceWasMapFile, |
|
36 ESourceWasSymbolFile |
|
37 } |
|
38 #endregion |
|
39 |
|
40 #region Constructors & destructor |
|
41 public CodeSegResolverEntry() |
|
42 { |
|
43 } |
|
44 |
|
45 public CodeSegResolverEntry( string aFileName ) |
|
46 { |
|
47 EnvironmentFileNameAndPath = aFileName; |
|
48 ImageFileNameAndPath = Path.Combine( CodeSegResolver.KROMBinaryPath, Path.GetFileName( aFileName ) ).ToLower(); |
|
49 } |
|
50 |
|
51 public CodeSegResolverEntry( string aEnvFileName, string aImageFileName ) |
|
52 { |
|
53 EnvironmentFileNameAndPath = aEnvFileName.ToLower(); |
|
54 ImageFileNameAndPath = aImageFileName.ToLower(); |
|
55 } |
|
56 #endregion |
|
57 |
|
58 #region API |
|
59 #endregion |
|
60 |
|
61 #region Properties |
|
62 public TSourceType Source |
|
63 { |
|
64 get { return iSource; } |
|
65 set { iSource = value; } |
|
66 } |
|
67 |
|
68 public TBuildType BuildType |
|
69 { |
|
70 get { return iBuildType; } |
|
71 set { iBuildType = value; } |
|
72 } |
|
73 |
|
74 public string EnvironmentFileName |
|
75 { |
|
76 get { return Path.GetFileName( EnvironmentFileNameAndPath ); } |
|
77 } |
|
78 |
|
79 public string EnvironmentFileNameAndPath |
|
80 { |
|
81 get { return iFileNameAndPath_InEnvironment; } |
|
82 set |
|
83 { |
|
84 iFileNameAndPath_InEnvironment = value; |
|
85 |
|
86 // Try to identify the release type (build) based upon the |
|
87 // filename directory information. We'll default to UREL. |
|
88 if ( value.Length > 0 ) |
|
89 { |
|
90 iBuildType = BuildTypeByFileName( value ); |
|
91 } |
|
92 } |
|
93 } |
|
94 |
|
95 public string ImageFileName |
|
96 { |
|
97 get |
|
98 { |
|
99 string ret = string.Empty; |
|
100 string val = ImageFileNameAndPath; |
|
101 // |
|
102 if ( !string.IsNullOrEmpty( val ) ) |
|
103 { |
|
104 // Try to get rid of all file extensions |
|
105 while ( ret == string.Empty ) |
|
106 { |
|
107 try |
|
108 { |
|
109 ret = Path.GetFileName( val ); |
|
110 } |
|
111 catch ( ArgumentException ) |
|
112 { |
|
113 if ( val.Length > 0 ) |
|
114 { |
|
115 val = val.Substring( 0, val.Length - 1 ); |
|
116 } |
|
117 else |
|
118 { |
|
119 break; |
|
120 } |
|
121 } |
|
122 } |
|
123 } |
|
124 // |
|
125 return ret; |
|
126 } |
|
127 } |
|
128 |
|
129 public string ImageFileNameAndPath |
|
130 { |
|
131 get { return iFileNameAndPath_InImage; } |
|
132 set |
|
133 { |
|
134 iFileNameAndPath_InImage = value; |
|
135 } |
|
136 } |
|
137 |
|
138 public string ImageFileNameAndPathWithoutDrive |
|
139 { |
|
140 get |
|
141 { |
|
142 string withoutDrive = Path.GetDirectoryName( ImageFileNameAndPath ); |
|
143 // |
|
144 if ( withoutDrive.Length > 2 && withoutDrive[ 1 ] == ':' && withoutDrive[ 2 ] == '\\' ) |
|
145 { |
|
146 withoutDrive = withoutDrive.Substring( 2 ); |
|
147 } |
|
148 if ( withoutDrive.Length > 0 && withoutDrive[ withoutDrive.Length - 1 ] != Path.DirectorySeparatorChar ) |
|
149 { |
|
150 withoutDrive += Path.DirectorySeparatorChar; |
|
151 } |
|
152 // |
|
153 withoutDrive += Path.GetFileName( ImageFileNameAndPath ); |
|
154 return withoutDrive; |
|
155 } |
|
156 } |
|
157 #endregion |
|
158 |
|
159 #region From System.Object |
|
160 public override string ToString() |
|
161 { |
|
162 return ImageFileNameAndPath.ToLower(); |
|
163 } |
|
164 |
|
165 public override bool Equals( object aObject ) |
|
166 { |
|
167 bool isEqual = false; |
|
168 // |
|
169 if ( aObject != null ) |
|
170 { |
|
171 if ( aObject is CodeSegResolverEntry ) |
|
172 { |
|
173 CodeSegResolverEntry otherEntry = aObject as CodeSegResolverEntry; |
|
174 // |
|
175 isEqual = ( otherEntry.ImageFileNameAndPathWithoutDrive.ToLower() == ImageFileNameAndPathWithoutDrive.ToLower() ); |
|
176 } |
|
177 } |
|
178 // |
|
179 return isEqual; |
|
180 } |
|
181 |
|
182 public override int GetHashCode() |
|
183 { |
|
184 return ImageFileNameAndPath.GetHashCode(); |
|
185 } |
|
186 #endregion |
|
187 |
|
188 #region Internal methods |
|
189 private static TBuildType BuildTypeByFileName( string aFileName ) |
|
190 { |
|
191 TBuildType ret = TBuildType.EReleaseTypeRelease; |
|
192 string path = "UREL"; |
|
193 try |
|
194 { |
|
195 path = Path.GetDirectoryName( aFileName ).ToUpper(); |
|
196 } |
|
197 finally |
|
198 { |
|
199 } |
|
200 // |
|
201 if ( path == "UDEB" ) |
|
202 { |
|
203 } |
|
204 else |
|
205 { |
|
206 ret = TBuildType.EReleaseTypeRelease; |
|
207 } |
|
208 // |
|
209 return ret; |
|
210 } |
|
211 #endregion |
|
212 |
|
213 #region Data members |
|
214 private string iFileNameAndPath_InEnvironment = string.Empty; |
|
215 private string iFileNameAndPath_InImage = string.Empty; |
|
216 private TBuildType iBuildType = TBuildType.EReleaseTypeRelease; |
|
217 private TSourceType iSource = TSourceType.ESourceNotDefined; |
|
218 #endregion |
|
219 } |
|
220 } |