1 package org
.tianocore
.migration
;
5 import java
.util
.regex
.*;
6 import org
.tianocore
.*;
8 public class ModuleReader
{
9 ModuleReader(String path
, ModuleInfo moduleinfo
, Database database
) {
14 private String modulepath
;
15 private ModuleInfo mi
;
18 private static Pattern ptninfequation
= Pattern
.compile("([^ ]*) *= *([^ ]*)");
20 public void readMsa(String name
) throws Exception
{
21 ModuleSurfaceAreaDocument msadoc
= ModuleSurfaceAreaDocument
.Factory
.parse(new File(modulepath
+ File
.separator
+ name
));
22 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= msadoc
.getModuleSurfaceArea();
23 MsaHeaderDocument
.MsaHeader msaheader
= msa
.getMsaHeader();
25 mi
.modulename
= msaheader
.getModuleName();
26 mi
.guidvalue
= msaheader
.getGuidValue();
27 mi
.moduletype
= msaheader
.getModuleType().toString(); // ???
29 SourceFilesDocument
.SourceFiles sourcefiles
= msa
.getSourceFiles();
32 Iterator
<FilenameDocument
.Filename
> li
= sourcefiles
.getFilenameList().iterator();
33 while (li
.hasNext()) {
34 if (!mi
.localmodulesources
.contains(temp
= li
.next().toString())) {
35 System
.out
.println("Source File Missing ! : " + temp
);
40 public void readInf(String name
) throws Exception
{
41 System
.out
.println("Reading From Inf : " + name
);
42 BufferedReader rd
= new BufferedReader(new FileReader(modulepath
+ File
.separator
+ name
));
45 boolean inSrc
= false;
46 Matcher mtrinfequation
;
48 while ((line
= rd
.readLine()) != null) {
49 if (line
.length() != 0) {
51 if (line
.contains("[")) {
54 linecontext
= line
.split(" ");
55 if (linecontext
[2].length() != 0) {
56 if (!mi
.localmodulesources
.contains(linecontext
[2])) {
57 System
.out
.println("Source File Missing ! : " + linecontext
[2]);
62 if ((mtrinfequation
= ptninfequation
.matcher(line
)).find()) {
63 if (mtrinfequation
.group(1).matches("BASE_NAME")) {
64 mi
.modulename
= mtrinfequation
.group(2);
66 if (mtrinfequation
.group(1).matches("FILE_GUID")) {
67 mi
.guidvalue
= mtrinfequation
.group(2);
69 if (mtrinfequation
.group(1).matches("COMPONENT_TYPE")) {
70 mi
.moduletype
= mtrinfequation
.group(2);
72 if (mtrinfequation
.group(1).matches("IMAGE_ENTRY_POINT")) {
73 mi
.entrypoint
= mtrinfequation
.group(2);
76 if (line
.contains("sources")) {