From: Noah Watkins Date: Sun, 4 Nov 2012 18:11:18 +0000 (-0800) Subject: java: use accessors for mode flag tests X-Git-Tag: v0.55~193^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6aa9cff21962692b166a3b5d181f975db581722b;p=ceph.git java: use accessors for mode flag tests Add isDir(), isFile(), and isSymlink() for read-only tests corresponding to the S_ISREG test and friends. Signed-off-by: Noah Watkins Reviewed-by: Joe Buck --- diff --git a/src/java/java/com/ceph/fs/CephStat.java b/src/java/java/com/ceph/fs/CephStat.java index a2f5a7460c1..12aa8c98e9f 100644 --- a/src/java/java/com/ceph/fs/CephStat.java +++ b/src/java/java/com/ceph/fs/CephStat.java @@ -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; + } + } diff --git a/src/java/test/CephMountTest.java b/src/java/test/CephMountTest.java index 2bf26c8ad3e..0b0d1a2915c 100644 --- a/src/java/test/CephMountTest.java +++ b/src/java/test/CephMountTest.java @@ -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 */