-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing the resource file and delete option
- Loading branch information
1 parent
ba9dfbb
commit a1ef5ce
Showing
4 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ | |
</archive> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,17 @@ Tableau Editor Copyright (C) 2018 Rishu Kumar Shrivastava (rishu.shrivastava@g | |
*/ | ||
package org.tableau.editor.build; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.FileVisitResult; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.SimpleFileVisitor; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipOutputStream; | ||
|
||
|
||
/** | ||
* Zip the file back after the editing. | ||
* @author Rishu Shrivastava ([email protected]) | ||
|
@@ -30,6 +33,7 @@ public class BuildContent { | |
|
||
public boolean buildContent(String sourcedirpath, String Zipfilepath) { | ||
|
||
|
||
Path p; | ||
try { | ||
p = Files.createFile(Paths.get(Zipfilepath)); | ||
|
@@ -49,15 +53,43 @@ public boolean buildContent(String sourcedirpath, String Zipfilepath) { | |
} | ||
}); | ||
} | ||
|
||
} catch (IOException e1) { | ||
e1.printStackTrace(); | ||
return false; | ||
} | ||
|
||
//cleanup source directory path | ||
new File(sourcedirpath).deleteOnExit(); | ||
|
||
if(!deleteDir(sourcedirpath)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public boolean deleteDir(String sourcepath) { | ||
//delete the path recursively | ||
Path p = Paths.get(sourcepath); | ||
try { | ||
Files.walkFileTree(p, new SimpleFileVisitor<Path>(){ | ||
|
||
@Override | ||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { | ||
Files.delete(file); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { | ||
|
||
Files.delete(dir); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
}); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters