|
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.Threading; |
|
20 using System.Text; |
|
21 using System.Text.RegularExpressions; |
|
22 using System.Collections.Specialized; |
|
23 using System.Collections.Generic; |
|
24 using System.ComponentModel; |
|
25 using SymbianUtils; |
|
26 using SymbianUtils.SerializedOperations; |
|
27 using SymbolLib.Sources.Map.Parser; |
|
28 |
|
29 namespace SymbolLib.CodeSegDef |
|
30 { |
|
31 internal class CSROpScanObey : CodeSegResolverOperation |
|
32 { |
|
33 #region Constructors |
|
34 public CSROpScanObey( CodeSegResolver aResolver, bool aResetResolver, FileInfo aFile ) |
|
35 : base( aResolver, aResetResolver ) |
|
36 { |
|
37 iFile = aFile; |
|
38 } |
|
39 #endregion |
|
40 |
|
41 #region From CSROperation |
|
42 protected override void Scan() |
|
43 { |
|
44 base.DriveLetter = Path.GetPathRoot( iFile.FullName ); |
|
45 if ( iFile.Exists ) |
|
46 { |
|
47 using ( StreamReader reader = new StreamReader( iFile.FullName ) ) |
|
48 { |
|
49 string line = reader.ReadLine(); |
|
50 // |
|
51 while ( line != null ) |
|
52 { |
|
53 Match m = KMapParserRegex.Match( line ); |
|
54 if ( m.Success ) |
|
55 { |
|
56 string nameHost = base.CombineWithDriveLetter( m.Groups[ "Host]" ].Value ); |
|
57 string nameDevice = Path.Combine( KRomDriveFileLetter, m.Groups[ "Device" ].Value ); |
|
58 // |
|
59 CodeSegResolverEntry entry = new CodeSegResolverEntry( nameHost, nameDevice ); |
|
60 // |
|
61 base.Add( entry ); |
|
62 } |
|
63 // |
|
64 line = reader.ReadLine(); |
|
65 } |
|
66 } |
|
67 } |
|
68 } |
|
69 #endregion |
|
70 |
|
71 #region API |
|
72 #endregion |
|
73 |
|
74 #region Properties |
|
75 #endregion |
|
76 |
|
77 #region Internal methods |
|
78 #endregion |
|
79 |
|
80 #region Internal constants |
|
81 private const string KRomDriveFileLetter = "Z:\\"; |
|
82 #endregion |
|
83 |
|
84 #region Data members |
|
85 private readonly FileInfo iFile; |
|
86 public static readonly Regex KMapParserRegex = new Regex( |
|
87 "(?<Type>.+)\r\n\\=\r\n(?<Host>.+?)(?:\\s+)\\x22(?<Device>.+)\\x2" + |
|
88 "2", |
|
89 RegexOptions.CultureInvariant |
|
90 | RegexOptions.IgnorePatternWhitespace |
|
91 | RegexOptions.Compiled |
|
92 ); |
|
93 #endregion |
|
94 } |
|
95 } |