aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBen Gruver <bgruv@google.com>2016-04-23 09:18:22 -0700
committerBen Gruver <bgruv@google.com>2016-05-28 18:51:42 -0700
commite474301e60b89d33343586b896efd8e4b0a10b37 (patch)
tree29e2221799b100b81bc918f1cc87eeb04c4a4147 /util
parent8a5a6e3fc57adffebd9c9b717af85b66159a1208 (diff)
downloadsmali-e474301e60b89d33343586b896efd8e4b0a10b37.tar.gz
Revamp how classpath loading works
Diffstat (limited to 'util')
-rw-r--r--util/src/main/java/org/jf/util/PathUtil.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/util/src/main/java/org/jf/util/PathUtil.java b/util/src/main/java/org/jf/util/PathUtil.java
index 91eb7584..93cd01ba 100644
--- a/util/src/main/java/org/jf/util/PathUtil.java
+++ b/util/src/main/java/org/jf/util/PathUtil.java
@@ -28,9 +28,12 @@
package org.jf.util;
+import com.google.common.collect.Lists;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
public class PathUtil {
private PathUtil() {
@@ -55,8 +58,8 @@ public class PathUtil {
}
static String getRelativeFileInternal(File canonicalBaseFile, File canonicalFileToRelativize) {
- ArrayList<String> basePath = getPathComponents(canonicalBaseFile);
- ArrayList<String> pathToRelativize = getPathComponents(canonicalFileToRelativize);
+ List<String> basePath = getPathComponents(canonicalBaseFile);
+ List<String> pathToRelativize = getPathComponents(canonicalFileToRelativize);
//if the roots aren't the same (i.e. different drives on a windows machine), we can't construct a relative
//path from one to the other, so just return the canonical file
@@ -105,21 +108,21 @@ public class PathUtil {
return sb.toString();
}
- private static ArrayList<String> getPathComponents(File file) {
+ public static List<String> getPathComponents(File file) {
ArrayList<String> path = new ArrayList<String>();
while (file != null) {
File parentFile = file.getParentFile();
if (parentFile == null) {
- path.add(0, file.getPath());
+ path.add(file.getPath());
} else {
- path.add(0, file.getName());
+ path.add(file.getName());
}
file = parentFile;
}
- return path;
+ return Lists.reverse(path);
}
}