-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ground work for making mleap scala 2.13 compatible
1. Using sbt 1.9 2. Using most recent versions of the scala libraries where possible 3. Replaced scala-arm with more idiomatic scala 2.13+ way (scala-arm was not updated for a long time) 4. Updated scalatest. 5. Updated ClassloaderUtils to use java 9 compatible code.
- Loading branch information
Showing
226 changed files
with
1,084 additions
and
1,002 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
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
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
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
72 changes: 18 additions & 54 deletions
72
bundle-ml/src/main/scala/ml/combust/bundle/serializer/FileUtil.scala
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 |
---|---|---|
@@ -1,76 +1,40 @@ | ||
package ml.combust.bundle.serializer | ||
|
||
import java.io.{File, FileInputStream, FileOutputStream} | ||
import java.util.zip.{ZipEntry, ZipInputStream, ZipOutputStream} | ||
|
||
import resource._ | ||
import java.io.File | ||
import java.util.zip.{ZipInputStream, ZipOutputStream} | ||
|
||
/** | ||
* Created by hollinwilkins on 9/11/16. | ||
*/ | ||
@deprecated("Prefer ml.combust.bundle.util.FileUtil object.") | ||
case class FileUtil() { | ||
import ml.combust.bundle.util.{FileUtil => FileUtils} | ||
@deprecated("use FileUtil.rmRF(Path).") | ||
def rmRF(path: File): Array[(String, Boolean)] = { | ||
Option(path.listFiles).map(_.flatMap(f => rmRF(f))).getOrElse(Array()) :+ (path.getPath -> path.delete) | ||
FileUtils.rmRF(path.toPath) | ||
} | ||
|
||
@deprecated("use extract(Path, Path).") | ||
def extract(source: File, dest: File): Unit = { | ||
dest.mkdirs() | ||
for(in <- managed(new ZipInputStream(new FileInputStream(source)))) { | ||
extract(in, dest) | ||
} | ||
FileUtils.extract(source.toPath, dest.toPath) | ||
} | ||
|
||
@deprecated("use extract(ZipInputStream, Path).") | ||
def extract(in: ZipInputStream, dest: File): Unit = { | ||
dest.mkdirs() | ||
val buffer = new Array[Byte](1024 * 1024) | ||
|
||
var entry = in.getNextEntry | ||
while(entry != null) { | ||
if(entry.isDirectory) { | ||
new File(dest, entry.getName).mkdirs() | ||
} else { | ||
val filePath = new File(dest, entry.getName) | ||
for(out <- managed(new FileOutputStream(filePath))) { | ||
var len = in.read(buffer) | ||
while(len > 0) { | ||
out.write(buffer, 0, len) | ||
len = in.read(buffer) | ||
} | ||
} | ||
} | ||
entry = in.getNextEntry | ||
} | ||
FileUtils.extract(in, dest.toPath) | ||
} | ||
|
||
@deprecated("use FileUtil.extract(Path, Path).") | ||
def zip(source: File, dest: File): Unit = { | ||
for(out <- managed(new ZipOutputStream(new FileOutputStream(dest)))) { | ||
zip(source, out) | ||
} | ||
FileUtils.zip(source.toPath, dest.toPath) | ||
} | ||
|
||
def zip(source: File, dest: ZipOutputStream): Unit = zip(source, source, dest) | ||
@deprecated("use FileUtil.extract(Path, ZipOutputStream).") | ||
def zip(source: File, dest: ZipOutputStream): Unit = FileUtils.zip(source.toPath, source.toPath, dest) | ||
|
||
@deprecated("use FileUtil.extract(Path, Path, ZipOutputStream).") | ||
def zip(base: File, source: File, dest: ZipOutputStream): Unit = { | ||
val buffer = new Array[Byte](1024 * 1024) | ||
|
||
for(files <- Option(source.listFiles); | ||
file <- files) { | ||
val name = file.toString.substring(base.toString.length + 1) | ||
|
||
if(file.isDirectory) { | ||
dest.putNextEntry(new ZipEntry(s"$name/")) | ||
zip(base, file, dest) | ||
} else { | ||
dest.putNextEntry(new ZipEntry(name)) | ||
|
||
for (in <- managed(new FileInputStream(file))) { | ||
var read = in.read(buffer) | ||
while (read > 0) { | ||
dest.write(buffer, 0, read) | ||
read = in.read(buffer) | ||
} | ||
} | ||
} | ||
} | ||
FileUtils.zip(base.toPath, source.toPath, dest) | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.