mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-23 02:31:52 +01:00
Compare commits
5 Commits
c208c6a2ae
...
b628ea28bc
Author | SHA1 | Date | |
---|---|---|---|
|
b628ea28bc | ||
|
2e150358ad | ||
|
907ece2810 | ||
|
20dacabd20 | ||
|
76089a3466 |
@ -7,6 +7,7 @@ import java.io.InputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class NativeUtils {
|
public final class NativeUtils {
|
||||||
|
|
||||||
@ -19,7 +20,8 @@ public final class NativeUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static File unpackLibraryFromJarInternal(String path) throws IOException {
|
private static File unpackLibraryFromJarInternal(String path) throws IOException {
|
||||||
if (null == path || !path.startsWith("/")) {
|
Objects.requireNonNull(path, "The path cannot be null.");
|
||||||
|
if (!path.startsWith("/")) {
|
||||||
throw new IllegalArgumentException("The path has to be absolute (start with '/').");
|
throw new IllegalArgumentException("The path has to be absolute (start with '/').");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,12 +32,8 @@ public final class NativeUtils {
|
|||||||
throw new IllegalArgumentException("The filename has to be at least 3 characters long.");
|
throw new IllegalArgumentException("The filename has to be at least 3 characters long.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temporaryDir == null) {
|
File temp = Files.createTempFile(NATIVE_FOLDER_PATH_PREFIX, filename).toFile();
|
||||||
temporaryDir = createTempDirectory(NATIVE_FOLDER_PATH_PREFIX);
|
temp.deleteOnExit();
|
||||||
temporaryDir.deleteOnExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
File temp = new File(temporaryDir, filename);
|
|
||||||
|
|
||||||
try (InputStream is = NativeUtils.class.getResourceAsStream(path)) {
|
try (InputStream is = NativeUtils.class.getResourceAsStream(path)) {
|
||||||
Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
Loading…
Reference in New Issue
Block a user