]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FileParser.java
Updated PeiRebase to produce a map file of the relocations done by this tool. This...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / FileParser.java
1 /** @file
2 FileParser class.
3
4 FileParser class is to parse file which contains the list of file name and
5 add those files to list.
6
7
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18 package org.tianocore.framework.tasks;
19 import java.io.*;
20 import java.util.List;
21
22 import org.apache.tools.ant.BuildException;
23 import org.apache.tools.ant.Project;
24
25 /**
26 FileParser class.
27
28 FileParser class is to parse file which contains the list of file name and
29 add those files to list.
30 **/
31 public class FileParser {
32 /**
33 loadFile
34
35 This function is to add files to array from input file which contains the
36 files list.
37 @param project The current project.
38 @param list File array.
39 @param file File which contains the file list.
40 @param tag Target of architecture.
41 @throws BuildException
42 **/
43 public static synchronized void loadFile(Project project, List<Object> list, File file, String tag) throws BuildException{
44 FileReader fileReader;
45 BufferedReader in;
46 String str;
47
48 if (!file.exists()) {
49 throw new BuildException("The file" + file + "is not exist");
50 }
51 try {
52 fileReader = new FileReader(file);
53 in = new BufferedReader(fileReader);
54 while((str=in.readLine())!= null){
55 if (str.trim()==""){
56 continue;
57 }
58 str = project.replaceProperties(str);
59 if (str.trim().substring(0,2).equalsIgnoreCase(tag)) {
60 list.add(str.trim());
61 } else {
62 list.add(tag + " " + str.trim());
63 }
64
65 }
66 } catch (Exception e){
67 System.out.println(e.getMessage());
68
69 }
70 }
71
72 }