[IO] Add FileUtils.requireParent
diff --git a/jcommons/org.eclipse.statet.jcommons.util/src/org/eclipse/statet/jcommons/io/FileUtils.java b/jcommons/org.eclipse.statet.jcommons.util/src/org/eclipse/statet/jcommons/io/FileUtils.java
index 922bcee..76d2d78 100644
--- a/jcommons/org.eclipse.statet.jcommons.util/src/org/eclipse/statet/jcommons/io/FileUtils.java
+++ b/jcommons/org.eclipse.statet.jcommons.util/src/org/eclipse/statet/jcommons/io/FileUtils.java
@@ -48,6 +48,21 @@
/**
+ * Checks if the specified path has a {@link Path#getParent() parent} and returns it.
+ *
+ * @param path the path
+ * @return the parent of the path
+ * @throws IllegalArgumentException if the path does not have a parent
+ */
+ public static final Path requireParent(final Path path) {
+ final Path parent= path.getParent();
+ if (parent == null) {
+ throw new IllegalArgumentException("path does not have a parent"); //$NON-NLS-1$
+ }
+ return parent;
+ }
+
+ /**
* Checks if the specified path is not empty (= has a {@link Path#getFileName() file name}) and
* returns its file name.
*