From 6f5e10b0dc596c8e7625de7ddf523b6d5bc220c7 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Thu, 27 Feb 2014 08:17:06 +0000
Subject: [PATCH] Checkpoint for OPENDJ-1303 "opendj-cli" / Checkpoint OPENDJ-1343 Migrate dsconfig - Added CONFLICTING_ARGS to ReturnCode. - Added canWrite() to Utils + unit tests. - Replaced calls to org.opends.quicksetup.util.Utils.canWrite by com.forgerock.opendj.cli.Utils.canWrite. - Removed the TablePrinter classes from org.opends.server.util.table as they are now in the opendj-cli. - Minor code cleanup on DSConfig package. (reorganize imports).
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
index df5da38..e2e3d4c 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -489,6 +489,23 @@
return msg;
}
+ /**
+ * Returns <CODE>true</CODE> if we can write on the provided path and <CODE>false</CODE> otherwise.
+ *
+ * @param path
+ * the path.
+ * @return <CODE>true</CODE> if we can write on the provided path and <CODE>false</CODE> otherwise.
+ */
+ public static boolean canWrite(String path) {
+ final File file = new File(path);
+ if (file.exists()) {
+ return file.canWrite();
+ }
+ final File parentFile = file.getParentFile();
+ return (parentFile != null && parentFile.canWrite());
+ }
+
+
// Prevent instantiation.
private Utils() {
// Do nothing.
--
Gitblit v1.10.0