Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tapasco
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
52
Issues
52
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tapasco
tapasco
Commits
22cbefbd
Commit
22cbefbd
authored
Jun 06, 2017
by
Jens Korinth
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement zip creation method in utils
parent
14c8db46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
src/main/scala/tapasco/util/ZipUtils.scala
src/main/scala/tapasco/util/ZipUtils.scala
+21
-3
No files found.
src/main/scala/tapasco/util/ZipUtils.scala
View file @
22cbefbd
...
...
@@ -27,12 +27,11 @@ import scala.util.matching._
import
java.nio.file._
object
ZipUtils
{
/**
* Unpacks all files matching the given regular expressions into a temporary directory.
/** Unpacks all files matching the given regular expressions into a temporary directory.
* @param zipFile Path to .zip file.
* @param regexes List of regexes; all matching files will be extracted.
* @return tuple (temporary directory, list of extracted files).
*
*
/
*/
def
unzipFile
(
zipFile
:
Path
,
regexes
:
Seq
[
Regex
],
exclude
:
Seq
[
Regex
]
=
Seq
())
(
implicit
logger
:
Logger
)
:
(
Path
,
Seq
[
Path
])
=
{
import
java.util.zip._
...
...
@@ -69,4 +68,23 @@ object ZipUtils {
}
(
tempdir
,
extracted
)
}
/** Packs all given files into a zipFile.
* Throws IOException if something fails.
* @param zipFile Path to output zip file.
* @param files Sequence of files to pack.
*/
def
zipFile
(
zipFile
:
Path
,
files
:
Seq
[
Path
])
=
{
import
java.util.zip._
import
java.io.
{
BufferedOutputStream
,
FileOutputStream
}
val
zos
=
new
ZipOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
zipFile
.
toFile
)))
files
foreach
{
f
=>
val
ze
=
new
ZipEntry
(
f
.
toFile
.
getName
)
zos
.
putNextEntry
(
ze
)
var
amountRead
:
Int
=
0
zos
.
write
(
Files
.
readAllBytes
(
f
))
}
zos
.
flush
()
zos
.
close
()
}
}
Jens Korinth
@jk
mentioned in commit
a831b501
·
Jul 14, 2017
mentioned in commit
a831b501
mentioned in commit a831b5015df6bd8f8d23ddd334a3b1159392de92
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment