]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
java: use accessors for mode flag tests
authorNoah Watkins <noahwatkins@gmail.com>
Sun, 4 Nov 2012 18:11:18 +0000 (10:11 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Tue, 6 Nov 2012 21:50:38 +0000 (13:50 -0800)
Add isDir(), isFile(), and isSymlink() for read-only tests corresponding
to the S_ISREG test and friends.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Reviewed-by: Joe Buck <jbbuck@gmail.com>
src/java/java/com/ceph/fs/CephStat.java
src/java/test/CephMountTest.java

index a2f5a7460c1cd4f12f66cfcceab5cea010c4c46e..12aa8c98e9f0c9e048feed4c0b7bb68fb9dab0d7 100644 (file)
@@ -23,6 +23,12 @@ package com.ceph.fs;
  * Holds struct stat fields.
  */
 public class CephStat {
+
+  /* Set from native */
+  private boolean is_file;       /* S_ISREG */
+  private boolean is_directory;  /* S_ISDIR */
+  private boolean is_symlink;    /* S_ISLNK */
+
   public int mode;
   public int uid;
   public int gid;
@@ -32,14 +38,16 @@ public class CephStat {
   public long a_time;
   public long m_time;
 
-  /*
-   * Results from the following tests:
-   *
-   *   - S_ISREG
-   *   - S_ISDIR
-   *   - S_ISLNK
-   */
-  public boolean is_file;
-  public boolean is_directory;
-  public boolean is_symlink;
+  public boolean isFile() {
+    return is_file;
+  }
+
+  public boolean isDir() {
+    return is_directory;
+  }
+
+  public boolean isSymlink() {
+    return is_symlink;
+  }
+
 }
index 2bf26c8ad3e124a58f348e8a0de150bed806e640..0b0d1a2915cf0241343c944ca93d2434de97dd1b 100644 (file)
@@ -372,7 +372,7 @@ public class CephMountTest {
     mount.mkdir(path, 0777);
     CephStat st = new CephStat();
     mount.lstat(path, st);
-    assertTrue(st.is_directory);
+    assertTrue(st.isDir());
     mount.rmdir(path);
   }
 
@@ -383,13 +383,13 @@ public class CephMountTest {
 
     CephStat st = new CephStat();
     mount.lstat(path, st);
-    assertTrue(st.is_directory);
+    assertTrue(st.isDir());
 
     mount.lstat(path + "/x", st);
-    assertTrue(st.is_directory);
+    assertTrue(st.isDir());
 
     mount.lstat(path + "/x/y", st);
-    assertTrue(st.is_directory);
+    assertTrue(st.isDir());
 
     mount.rmdir(path + "/x/y");
     mount.rmdir(path + "/x");
@@ -403,7 +403,7 @@ public class CephMountTest {
     mount.mkdir(path, 0777);
     CephStat st = new CephStat();
     mount.lstat(path, st);
-    assertTrue(st.is_directory);
+    assertTrue(st.isDir());
     /* remove it */
     mount.rmdir(path);
     /* should not exist now */