mirror of https://github.com/termux/termux-app
Added: Add TermuxFileUtils.getExpandedTermuxPaths() and TermuxFileUtils.getUnExpandedTermuxPaths()
This commit is contained in:
parent
1f0f80b0c9
commit
f3ffc36bfd
|
@ -17,12 +17,31 @@ import com.termux.shared.termux.TermuxConstants;
|
||||||
import com.termux.shared.termux.TermuxUtils;
|
import com.termux.shared.termux.TermuxUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class TermuxFileUtils {
|
public class TermuxFileUtils {
|
||||||
|
|
||||||
private static final String LOG_TAG = "TermuxFileUtils";
|
private static final String LOG_TAG = "TermuxFileUtils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace "$PREFIX/" or "~/" prefix with termux absolute paths.
|
||||||
|
*
|
||||||
|
* @param paths The {@code paths} to expand.
|
||||||
|
* @return Returns the {@code expand paths}.
|
||||||
|
*/
|
||||||
|
public static List<String> getExpandedTermuxPaths(List<String> paths) {
|
||||||
|
if (paths == null) return null;
|
||||||
|
List<String> expandedPaths = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < paths.size(); i++) {
|
||||||
|
expandedPaths.add(getExpandedTermuxPath(paths.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return expandedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace "$PREFIX/" or "~/" prefix with termux absolute paths.
|
* Replace "$PREFIX/" or "~/" prefix with termux absolute paths.
|
||||||
*
|
*
|
||||||
|
@ -40,6 +59,23 @@ public class TermuxFileUtils {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace termux absolute paths with "$PREFIX/" or "~/" prefix.
|
||||||
|
*
|
||||||
|
* @param paths The {@code paths} to unexpand.
|
||||||
|
* @return Returns the {@code unexpand paths}.
|
||||||
|
*/
|
||||||
|
public static List<String> getUnExpandedTermuxPaths(List<String> paths) {
|
||||||
|
if (paths == null) return null;
|
||||||
|
List<String> unExpandedPaths = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < paths.size(); i++) {
|
||||||
|
unExpandedPaths.add(getUnExpandedTermuxPath(paths.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return unExpandedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace termux absolute paths with "$PREFIX/" or "~/" prefix.
|
* Replace termux absolute paths with "$PREFIX/" or "~/" prefix.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue