| 6737 | |
| 6738 | |
| 6739 | public String[] listPaths(String path, String... options) { |
| 6740 | File[] list = listFiles(path, options); |
| 6741 | |
| 6742 | int offset = 0; |
| 6743 | for (String opt : options) { |
| 6744 | if (opt.equals("relative")) { |
| 6745 | if (!path.endsWith(File.pathSeparator)) { |
| 6746 | path += File.pathSeparator; |
| 6747 | } |
| 6748 | offset = path.length(); |
| 6749 | break; |
| 6750 | } |
| 6751 | } |
| 6752 | String[] outgoing = new String[list.length]; |
| 6753 | for (int i = 0; i < list.length; i++) { |
| 6754 | // as of Java 1.8, substring(0) returns the original object |
| 6755 | outgoing[i] = list[i].getAbsolutePath().substring(offset); |
| 6756 | } |
| 6757 | return outgoing; |
| 6758 | } |
| 6759 | |
| 6760 | |
| 6761 | public File[] listFiles(String path, String... options) { |