|
17 | 17 | import java.io.OutputStream;
|
18 | 18 | import java.nio.file.Files;
|
19 | 19 | import java.nio.file.Path;
|
| 20 | +import java.nio.file.Paths; |
20 | 21 | import java.util.zip.GZIPInputStream;
|
21 | 22 | import java.util.zip.ZipEntry;
|
22 | 23 | import java.util.zip.ZipInputStream;
|
@@ -172,12 +173,22 @@ public static void extractTar(File file, File destination) throws IOException {
|
172 | 173 | break;
|
173 | 174 | case TarEntry.LINK:
|
174 | 175 | File linkFile = new File(destination, outFilename);
|
175 |
| - Path target = new File(linkFile.getParentFile(), entry.getLinkName()).toPath(); |
| 176 | + // Be sure that parent file exists |
| 177 | + File linkBaseDir = linkFile.getParentFile(); |
| 178 | + if (!linkBaseDir.exists()) { |
| 179 | + linkBaseDir.mkdirs(); |
| 180 | + } |
| 181 | + Path target = Paths.get(entry.getLinkName()); |
176 | 182 | Files.createLink(linkFile.toPath(), target);
|
177 | 183 | break;
|
178 | 184 | case TarEntry.SYM_LINK:
|
179 | 185 | File symLinkFile = new File(destination, outFilename);
|
180 |
| - Path symTarget = new File(symLinkFile.getParentFile(), entry.getLinkName()).toPath(); |
| 186 | + // Be sure that parent file exists |
| 187 | + File symLinkBaseDir = symLinkFile.getParentFile(); |
| 188 | + if (!symLinkBaseDir.exists()) { |
| 189 | + symLinkBaseDir.mkdirs(); |
| 190 | + } |
| 191 | + Path symTarget = Paths.get(entry.getLinkName()); |
181 | 192 | Files.createSymbolicLink(symLinkFile.toPath(), symTarget);
|
182 | 193 | break;
|
183 | 194 | }
|
|
0 commit comments