IO reference, representing a local file or directory path. @author BaseX Team, BSD License @author Christian Gruen
| 19 | * @author Christian Gruen |
| 20 | */ |
| 21 | public final class IOFile extends IO { |
| 22 | /** Ignore files starting with a dot. */ |
| 23 | public static final FileFilter NO_HIDDEN = file -> !Strings.startsWith(file.getName(), '.'); |
| 24 | /** Pattern for valid file names. */ |
| 25 | private static final Pattern VALIDNAME = |
| 26 | Pattern.compile("^[^\\\\/" + (Prop.WIN ? ":*?\"<>|" : "") + "]+$"); |
| 27 | |
| 28 | /** Absolute flag. */ |
| 29 | private final boolean absolute; |
| 30 | /** File reference. */ |
| 31 | private final File file; |
| 32 | |
| 33 | /** |
| 34 | * Constructor. |
| 35 | * @param path path reference |
| 36 | */ |
| 37 | public IOFile(final Path path) { |
| 38 | this(path.toFile(), ""); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Constructor. |
| 43 | * @param file file reference |
| 44 | */ |
| 45 | public IOFile(final File file) { |
| 46 | this(file, ""); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Constructor. |
| 51 | * @param path file path |
| 52 | */ |
| 53 | public IOFile(final String path) { |
| 54 | this(new File(path), path); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Constructor. |
| 59 | * @param dir parent directory string |
| 60 | * @param child child directory string |
| 61 | */ |
| 62 | public IOFile(final String dir, final String child) { |
| 63 | this(new File(dir, child), child); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Constructor. |
| 68 | * @param dir directory string |
| 69 | * @param child child path string |
| 70 | */ |
| 71 | public IOFile(final IOFile dir, final String child) { |
| 72 | this(new File(dir.file, child), child); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Constructor. |
| 77 | * @param file file reference |
| 78 | * @param last last path segment; if it ends with a slash, it indicates a directory |
nothing calls this directly
no test coverage detected