Changeset 605 for AE/installer2/src/net/oni2/aeinstaller/backend/unpack
- Timestamp:
- Jan 13, 2013, 8:11:07 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/unpack/Unpacker.java
r604 r605 117 117 try { 118 118 int pathStart = 0; 119 String pathStartName = ""; 119 120 120 121 ZipFile zf = new ZipFile(zip); … … 124 125 ZipEntry ze = e.nextElement(); 125 126 if (ze.getName().toLowerCase() 126 .endsWith("mod_info.cfg")) { 127 .endsWith("/mod_info.cfg") 128 || ze.getName().toLowerCase() 129 .equals("mod_info.cfg")) { 127 130 pathStart = ze.getName().toLowerCase() 128 131 .indexOf("mod_info.cfg"); 132 pathStartName = ze.getName().substring(0, 133 pathStart); 129 134 } 130 135 } … … 136 141 ZipEntry ze = e.nextElement(); 137 142 if (!ze.isDirectory()) { 138 File targetFile = new File(target, ze.getName() 139 .substring(pathStart)); 140 targetFile.getParentFile().mkdirs(); 143 if (ze.getName().startsWith(pathStartName)) { 144 File targetFile = new File(target, ze 145 .getName().substring(pathStart)); 146 File parent = targetFile.getParentFile(); 147 parent.mkdirs(); 141 148 142 InputStream in = zf.getInputStream(ze);149 InputStream in = zf.getInputStream(ze); 143 150 144 int read = 0; 145 byte[] data = new byte[1024]; 146 FileOutputStream fileOut = new FileOutputStream( 147 targetFile); 148 while ((read = in.read(data, 0, 1024)) != -1) { 149 fileOut.write(data, 0, read); 151 int read = 0; 152 byte[] data = new byte[1024]; 153 FileOutputStream fileOut = new FileOutputStream( 154 targetFile); 155 while ((read = in.read(data, 0, 1024)) != -1) { 156 fileOut.write(data, 0, read); 157 } 158 fileOut.close(); 150 159 } 151 fileOut.close();152 160 } 153 161 }
Note:
See TracChangeset
for help on using the changeset viewer.