-
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.
- Loading branch information
Showing
6 changed files
with
81 additions
and
79 deletions.
There are no files selected for viewing
45 changes: 0 additions & 45 deletions
45
src/standard-library/src/main/java/org/smoothbuild/stdlib/compress/UnzipHelper.java
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
44 changes: 44 additions & 0 deletions
44
src/standard-library/src/main/java/org/smoothbuild/stdlib/file/FileHelper.java
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.smoothbuild.stdlib.file; | ||
|
||
import static org.smoothbuild.virtualmachine.bytecode.helper.FileStruct.filePath; | ||
|
||
import java.util.HashMap; | ||
import org.smoothbuild.virtualmachine.bytecode.BytecodeException; | ||
import org.smoothbuild.virtualmachine.bytecode.expr.base.BArray; | ||
import org.smoothbuild.virtualmachine.bytecode.expr.base.BTuple; | ||
import org.smoothbuild.virtualmachine.evaluate.plugin.NativeApi; | ||
|
||
public class FileHelper { | ||
public static HashMap<String, BTuple> fileArrayArrayToMap( | ||
NativeApi nativeApi, BArray fileArrayArray) throws BytecodeException { | ||
var result = new HashMap<String, BTuple>(); | ||
for (BArray fileArray : fileArrayArray.elements(BArray.class)) { | ||
if (fileArrayToMap(nativeApi, fileArray, result)) { | ||
return null; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public static HashMap<String, BTuple> fileArrayToMap(NativeApi nativeApi, BArray fileArray) | ||
throws BytecodeException { | ||
var result = new HashMap<String, BTuple>(); | ||
if (fileArrayToMap(nativeApi, fileArray, result)) { | ||
return null; | ||
} | ||
return result; | ||
} | ||
|
||
private static boolean fileArrayToMap( | ||
NativeApi nativeApi, BArray fileArray, HashMap<String, BTuple> result) | ||
throws BytecodeException { | ||
for (var entry : fileArray.elements(BTuple.class)) { | ||
var path = filePath(entry).toJavaString(); | ||
if (result.put(path, entry) != null) { | ||
nativeApi.log().error("File " + path + " is contained by two different library jar files."); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
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