jf = farFile;\r
this.mainfest = new Mainfest(getMainfestFile());\r
}\r
- \r
- public void creatFar (List<PackageIdentification> pkgList,\r
- List<PlatformIdentification> plfList, Set<String> fileFilter,\r
- FarHeader fHeader) throws Exception{\r
+\r
+ public void creatFar(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
+ Set<String> fileFilter, FarHeader fHeader) throws Exception {\r
jos = new JarOutputStream(new FileOutputStream(jarFile));\r
\r
//\r
}\r
jos.close();\r
}\r
- \r
- private void writeToJar(File file, JarOutputStream jos) throws Exception{\r
- byte[] buffer = new byte[(int)file.length()];\r
- FileInputStream fInput = new FileInputStream(file);\r
- JarEntry entry = new JarEntry(Tools.convertPathToUnixType(Tools.getRelativePath(file.getPath(),Workspace.getCurrentWorkspace())));\r
- jos.putNextEntry(entry);\r
- fInput.read(buffer);\r
- jos.write(buffer);\r
- fInput.close();\r
+\r
+ private void writeToJar(File file, JarOutputStream jos) throws Exception {\r
+ byte[] buffer = new byte[(int) file.length()];\r
+ FileInputStream fInput = new FileInputStream(file);\r
+ JarEntry entry = new JarEntry(\r
+ Tools\r
+ .convertPathToUnixType(Tools\r
+ .getRelativePath(file.getPath(),\r
+ Workspace.getCurrentWorkspace())));\r
+ jos.putNextEntry(entry);\r
+ fInput.read(buffer);\r
+ jos.write(buffer);\r
+ fInput.close();\r
}\r
\r
public void InstallFar(String dir) throws Exception {\r
List<FarFileItem> allFile = mainfest.getAllFileItem();\r
extract(allFile, dir);\r
}\r
- \r
- public void InstallFar (Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap) throws Exception{\r
+\r
+ public void InstallFar(Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap)\r
+ throws Exception {\r
Set<PlatformIdentification> plfKeys = plfMap.keySet();\r
Iterator<PlatformIdentification> plfIter = plfKeys.iterator();\r
while (plfIter.hasNext()) {\r
public boolean hibernateToFile() {\r
return true;\r
}\r
-// public static void main(String[] args){\r
-// try {\r
-// JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));\r
-// JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");\r
-// InputStream is = jarFile.getInputStream(je);\r
-// byte[] buffer = new byte[1]; \r
-// File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");\r
-// File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");\r
-// FileOutputStream fos1 = new FileOutputStream(tfile2);\r
-// FileOutputStream fos = new FileOutputStream(tempFile);\r
-// int size = is.read(buffer);\r
-// int totoalSize = size;\r
-// while ( size >= 0) {\r
-// fos.write(buffer);\r
-// size = is.read(buffer);\r
-// totoalSize = totoalSize + size;\r
-// }\r
-// \r
-// \r
-//// is = jarFile.getInputStream(je);\r
-//// is.read(totalbuffer);\r
-//// fos.write(totalbuffer);\r
-// fos.close();\r
-// byte[] totalbuffer = new byte[(int)tempFile.length()];\r
-// FileInputStream fis = new FileInputStream(tempFile);\r
-// fis.read(totalbuffer);\r
-// fos1.write(totalbuffer);\r
-// fos1.close();\r
-// }catch(Exception e){\r
-// \r
-// }\r
-// }\r
- \r
+\r
+ // public static void main(String[] args){\r
+ // try {\r
+ // JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));\r
+ // JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");\r
+ // InputStream is = jarFile.getInputStream(je);\r
+ // byte[] buffer = new byte[1]; \r
+ // File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");\r
+ // File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");\r
+ // FileOutputStream fos1 = new FileOutputStream(tfile2);\r
+ // FileOutputStream fos = new FileOutputStream(tempFile);\r
+ // int size = is.read(buffer);\r
+ // int totoalSize = size;\r
+ // while ( size >= 0) {\r
+ // fos.write(buffer);\r
+ // size = is.read(buffer);\r
+ // totoalSize = totoalSize + size;\r
+ // }\r
+ // \r
+ // \r
+ //// is = jarFile.getInputStream(je);\r
+ //// is.read(totalbuffer);\r
+ //// fos.write(totalbuffer);\r
+ // fos.close();\r
+ // byte[] totalbuffer = new byte[(int)tempFile.length()];\r
+ // FileInputStream fis = new FileInputStream(tempFile);\r
+ // fis.read(totalbuffer);\r
+ // fos1.write(totalbuffer);\r
+ // fos1.close();\r
+ // }catch(Exception e){\r
+ // \r
+ // }\r
+ // }\r
+\r
public void extract(List<FarFileItem> allFile, String dir) throws Exception {\r
\r
Iterator filesItem = allFile.iterator();\r
dir += File.separatorChar;\r
while (filesItem.hasNext()) {\r
try {\r
- ffItem = (FarFileItem)filesItem.next();\r
+ ffItem = (FarFileItem) filesItem.next();\r
je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));\r
InputStream entryStream = jf.getInputStream(je);\r
File file = new File(dir + ffItem.getRelativeFilename());\r
// exists).\r
//\r
FileOutputStream outputStream = new FileOutputStream(file);\r
- \r
\r
try {\r
//\r
// Read the entry data and write it to the output\r
// file.\r
//\r
- byte[] buffer = new byte[1]; \r
+ byte[] buffer = new byte[1];\r
File tempFile = new File("tempFile");\r
FileOutputStream fos = new FileOutputStream(tempFile);\r
int size = entryStream.read(buffer);\r
- while ( size >= 0) {\r
+ while (size >= 0) {\r
fos.write(buffer);\r
size = entryStream.read(buffer);\r
}\r
- \r
+\r
fos.close();\r
- byte[] totalBuffer = new byte[(int)tempFile.length()];\r
+ byte[] totalBuffer = new byte[(int) tempFile.length()];\r
FileInputStream fis = new FileInputStream(tempFile);\r
fis.read(totalBuffer);\r
outputStream.write(totalBuffer);\r
} finally {\r
}\r
}\r
- \r
- }\r
- \r
- \r
- public void addFileToFar (File file, JarOutputStream farOuputStream, String workDir){\r
- \r
+\r
+ }\r
+\r
+ public void addFileToFar(File file, JarOutputStream farOuputStream, String workDir) {\r
+\r
}\r
\r
/**\r
List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
\r
entry = this.mainfest.getPackgeSpd(pkgId);\r
+ if (entry == null) {\r
+ return result;\r
+ }\r
if (entry[0] != null) {\r
try {\r
JarEntry je;\r