Remove additional / or \ in relative path.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / id / PackageIdentification.java
CommitLineData
5f42a4ba 1/** @file\r
2This file is to define PackageIdentification class.\r
3\r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13\r
a29c47e0 14package org.tianocore.build.id;\r
15import java.io.File;\r
16\r
17import org.tianocore.build.global.GlobalData;\r
18\r
19public class PackageIdentification extends Identification{\r
20 \r
21 //\r
22 // It is optional\r
23 //\r
24 private File spdFile;\r
25 \r
26 public PackageIdentification(String guid, String version){\r
27 super(guid, version);\r
28 }\r
29 \r
30 public PackageIdentification(String name, String guid, String version){\r
31 super(name, guid, version);\r
32 }\r
33 \r
34 public PackageIdentification(String name, String guid, String version, String spdFilename){\r
35 super(name, guid, version);\r
36 this.spdFile = new File(spdFilename);\r
37 }\r
38 \r
39 public PackageIdentification(String name, String guid, String version, File spdFile){\r
40 super(name, guid, version);\r
41 this.spdFile = spdFile;\r
42 }\r
43 \r
44 public void setSpdFile(File spdFile) {\r
45 this.spdFile = spdFile;\r
46 }\r
47\r
48 public File getSpdFile() {\r
49 return spdFile;\r
50 }\r
51\r
52 public String toString(){\r
53 if (name == null) {\r
54 GlobalData.refreshPackageIdentification(this);\r
55 }\r
56 if (version == null || version.trim().equalsIgnoreCase("")) {\r
57 return "package [" + name + "]";\r
58 }\r
59 else {\r
60 return "package [" + name + " " + version + "]";\r
61 }\r
62 }\r
63 \r
64 public String getPackageDir(){\r
65 prepareSpdFile();\r
66 return spdFile.getParent();\r
67 }\r
68 \r
69 public String getPackageRelativeDir(){\r
70 prepareSpdFile();\r
53d853a6 71 String relativeDir =spdFile.getParent().substring(GlobalData.getWorkspacePath().length());\r
72 if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {\r
73 relativeDir = relativeDir.substring(1);\r
74 }\r
75 return relativeDir;\r
a29c47e0 76 }\r
77 \r
78 private void prepareSpdFile(){\r
79 if (spdFile == null) {\r
80 GlobalData.refreshPackageIdentification(this);\r
81 }\r
82 }\r
83 \r
84 public String getName() {\r
85 if (name == null) {\r
86 GlobalData.refreshPackageIdentification(this);\r
87 }\r
88 return name;\r
89 }\r
90}\r