summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java25
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c18
2 files changed, 43 insertions, 0 deletions
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index 1d65581a..6adeb211 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -3769,4 +3769,29 @@ public HashMap<String,String> test0rhashtableerr ()
private native String _df_h (long g)
throws LibGuestFSException;
+ /**
+ * estimate file space usage
+ * <p>
+ * This command runs the "du -s" command to estimate file
+ * space usage for "path".
+ * <p>
+ * "path" can be a file or a directory. If "path" is a
+ * directory then the estimate includes the contents of the
+ * directory and all subdirectories (recursively).
+ * <p>
+ * The result is the estimated size in *kilobytes* (ie.
+ * units of 1024 bytes).
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public long du (String path)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("du: handle is closed");
+ return _du (g, path);
+ }
+ private native long _du (long g, String path)
+ throws LibGuestFSException;
+
}
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index 206f2dc3..3b91b40c 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -4371,3 +4371,21 @@ Java_com_redhat_et_libguestfs_GuestFS__1df_1h
return jr;
}
+JNIEXPORT jlong JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1du
+ (JNIEnv *env, jobject obj, jlong jg, jstring jpath)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int64_t r;
+ const char *path;
+
+ path = (*env)->GetStringUTFChars (env, jpath, NULL);
+ r = guestfs_du (g, path);
+ (*env)->ReleaseStringUTFChars (env, jpath, path);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return 0;
+ }
+ return (jlong) r;
+}
+