Browse files

Move the rest of the FileStat implementations over to use an external…

… layout
  • Loading branch information...
1 parent a71f62a commit fd5aa6023dea71c7a2d976ea7f04d1476297c46b Wayne Meissner committed Mar 26, 2012
View
188 src/main/java/jnr/posix/BaseHeapFileStat.java
@@ -1,188 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-/**
- * $Id: $
- */
-
-package jnr.posix;
-
-/**
- *
- */
-public abstract class BaseHeapFileStat extends jnr.ffi.Struct implements FileStat {
- protected final POSIX posix;
-
- public BaseHeapFileStat(NativePOSIX posix) {
- super(posix.getRuntime());
- this.posix = posix;
- }
-
- public java.lang.String ftype() {
- if (isFile()) {
- return "file";
- } else if (isDirectory()) {
- return "directory";
- } else if (isCharDev()) {
- return "characterSpecial";
- } else if (isBlockDev()) {
- return "blockSpecial";
- } else if (isFifo()) {
- return "fifo";
- } else if (isSymlink()) {
- return "link";
- } else if (isSocket()) {
- return "socket";
- }
-
- return "unknown";
- }
-
- public boolean groupMember(int gid) {
- if (posix.getgid() == gid || posix.getegid() == gid) {
- return true;
- }
-
- // FIXME: Though not Posix, windows has different mechanism for this.
-
- return false;
- }
-
- public boolean isBlockDev() {
- return (mode() & S_IFMT) == S_IFBLK;
- }
-
- public boolean isCharDev() {
- return (mode() & S_IFMT) == S_IFCHR;
- }
-
- public boolean isDirectory() {
- return (mode() & S_IFMT) == S_IFDIR;
- }
-
- public boolean isEmpty() {
- return st_size() == 0;
- }
-
- public boolean isExecutable() {
- if (posix.geteuid() == 0) return (mode() & S_IXUGO) != 0;
- if (isOwned()) return (mode() & S_IXUSR) != 0;
- if (isGroupOwned()) return (mode() & S_IXGRP) != 0;
- return (mode() & S_IXOTH) != 0;
- }
-
- public boolean isExecutableReal() {
- if (posix.getuid() == 0) return (mode() & S_IXUGO) != 0;
- if (isROwned()) return (mode() & S_IXUSR) != 0;
- if (groupMember(gid())) return (mode() & S_IXGRP) != 0;
- return (mode() & S_IXOTH) != 0;
- }
-
- public boolean isFile() {
- return (mode() & S_IFMT) == S_IFREG;
- }
-
- public boolean isFifo() {
- return (mode() & S_IFMT) == S_IFIFO;
- }
-
- public boolean isGroupOwned() {
- return groupMember(gid());
- }
-
- public boolean isIdentical(FileStat other) {
- return dev() == other.dev() && ino() == other.ino();
- }
-
- public boolean isNamedPipe() {
- return (mode() & S_IFIFO) != 0;
- }
-
- public boolean isOwned() {
- return posix.geteuid() == uid();
- }
-
- public boolean isROwned() {
- return posix.getuid() == uid();
- }
-
- public boolean isReadable() {
- if (posix.geteuid() == 0) return true;
- if (isOwned()) return (mode() & S_IRUSR) != 0;
- if (isGroupOwned()) return (mode() & S_IRGRP) != 0;
- return (mode() & S_IROTH) != 0;
- }
-
- public boolean isReadableReal() {
- if (posix.getuid() == 0) return true;
- if (isROwned()) return (mode() & S_IRUSR) != 0;
- if (groupMember(gid())) return (mode() & S_IRGRP) != 0;
- return (mode() & S_IROTH) != 0;
- }
-
- public boolean isSetgid() {
- return (mode() & S_ISGID) != 0;
- }
-
- public boolean isSetuid() {
- return (mode() & S_ISUID) != 0;
- }
-
- public boolean isSocket() {
- return (mode() & S_IFMT) == S_IFSOCK;
- }
-
- public boolean isSticky() {
- return (mode() & S_ISVTX) != 0;
- }
-
- public boolean isSymlink() {
- return (mode() & S_IFMT) == S_IFLNK;
- }
-
- public boolean isWritable() {
- if (posix.geteuid() == 0) return true;
- if (isOwned()) return (mode() & S_IWUSR) != 0;
- if (isGroupOwned()) return (mode() & S_IWGRP) != 0;
- return (mode() & S_IWOTH) != 0;
- }
-
- public boolean isWritableReal() {
- if (posix.getuid() == 0) return true;
- if (isROwned()) return (mode() & S_IWUSR) != 0;
- if (groupMember(gid())) return (mode() & S_IWGRP) != 0;
- return (mode() & S_IWOTH) != 0;
- }
-
- public int major(long dev) {
- return (int) (dev >> 24) & 0xff;
- }
-
- public int minor(long dev) {
- return (int) (dev & 0xffffff);
- }
-}
View
127 src/main/java/jnr/posix/FreeBSDFileStat.java
@@ -0,0 +1,127 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ *
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+/**
+ * $Id: $
+ */
+
+package jnr.posix;
+
+import jnr.ffi.StructLayout;
+
+public final class FreeBSDFileStat extends BaseFileStat {
+ private static final class Layout extends StructLayout {
+
+ private Layout(jnr.ffi.Runtime runtime) {
+ super(runtime);
+ }
+
+ public final class time_t extends SignedLong {}
+ public final class dev_t extends Signed32 {}
+
+ public final dev_t st_dev = new dev_t();
+ public final Signed32 st_ino = new Signed32();
+ public final Signed16 st_mode = new Signed16();
+ public final Signed16 st_nlink = new Signed16();
+ public final Signed32 st_uid = new Signed32();
+ public final Signed32 st_gid = new Signed32();
+ public final dev_t st_rdev = new dev_t();
+ public final time_t st_atime = new time_t();
+ public final SignedLong st_atimensec = new SignedLong();
+ public final time_t st_mtime = new time_t();
+ public final SignedLong st_mtimensec = new SignedLong();
+ public final time_t st_ctime = new time_t();
+ public final SignedLong st_ctimensec = new SignedLong();
+ public final Signed64 st_size = new Signed64();
+ public final Signed64 st_blocks = new Signed64();
+ public final Signed32 st_blksize = new Signed32();
+ public final Signed32 st_flags = new Signed32();
+ public final Signed32 st_gen = new Signed32();
+ public final Signed32 st_lspare = new Signed32();
+ public final time_t st_birthtime = new time_t();
+ public final SignedLong st_birthtimensec = new SignedLong();
+ /* FIXME: This padding isn't quite correct */
+ public final Signed64 st_qspare0 = new Signed64();
+ }
+ private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime());
+
+ public FreeBSDFileStat(NativePOSIX posix) {
+ super(posix, layout);
+ }
+
+ public long atime() {
+ return layout.st_atime.get(memory);
+ }
+
+ public long blocks() {
+ return layout.st_blocks.get(memory);
+ }
+
+ public long blockSize() {
+ return layout.st_blksize.get(memory);
+ }
+
+ public long ctime() {
+ return layout.st_ctime.get(memory);
+ }
+
+ public long dev() {
+ return layout.st_dev.get(memory);
+ }
+
+ public int gid() {
+ return layout.st_gid.get(memory);
+ }
+
+ public long ino() {
+ return layout.st_ino.get(memory);
+ }
+
+ public int mode() {
+ return layout.st_mode.get(memory) & 0xffff;
+ }
+
+ public long mtime() {
+ return layout.st_mtime.get(memory);
+ }
+
+ public int nlink() {
+ return layout.st_nlink.get(memory);
+ }
+
+ public long rdev() {
+ return layout.st_rdev.get(memory);
+ }
+
+ public long st_size() {
+ return layout.st_size.get(memory);
+ }
+
+ public int uid() {
+ return layout.st_uid.get(memory);
+ }
+}
View
117 src/main/java/jnr/posix/FreeBSDHeapFileStat.java
@@ -1,117 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-/**
- * $Id: $
- */
-
-package jnr.posix;
-
-public final class FreeBSDHeapFileStat extends BaseHeapFileStat {
- public final class time_t extends SignedLong {}
- public final class dev_t extends Signed32 {}
-
- public final dev_t st_dev = new dev_t();
- public final Signed32 st_ino = new Signed32();
- public final Signed16 st_mode = new Signed16();
- public final Signed16 st_nlink = new Signed16();
- public final Signed32 st_uid = new Signed32();
- public final Signed32 st_gid = new Signed32();
- public final dev_t st_rdev = new dev_t();
- public final time_t st_atime = new time_t();
- public final SignedLong st_atimensec = new SignedLong();
- public final time_t st_mtime = new time_t();
- public final SignedLong st_mtimensec = new SignedLong();
- public final time_t st_ctime = new time_t();
- public final SignedLong st_ctimensec = new SignedLong();
- public final Signed64 st_size = new Signed64();
- public final Signed64 st_blocks = new Signed64();
- public final Signed32 st_blksize = new Signed32();
- public final Signed32 st_flags = new Signed32();
- public final Signed32 st_gen = new Signed32();
- public final Signed32 st_lspare = new Signed32();
- public final time_t st_birthtime = new time_t();
- public final SignedLong st_birthtimensec = new SignedLong();
- /* FIXME: This padding isn't quite correct */
- public final Signed64 st_qspare0 = new Signed64();
-
- public FreeBSDHeapFileStat(NativePOSIX posix) {
- super(posix);
- }
-
- public long atime() {
- return st_atime.get();
- }
-
- public long blocks() {
- return st_blocks.get();
- }
-
- public long blockSize() {
- return st_blksize.get();
- }
-
- public long ctime() {
- return st_ctime.get();
- }
-
- public long dev() {
- return st_dev.get();
- }
-
- public int gid() {
- return st_gid.get();
- }
-
- public long ino() {
- return st_ino.get();
- }
-
- public int mode() {
- return st_mode.get() & 0xffff;
- }
-
- public long mtime() {
- return st_mtime.get();
- }
-
- public int nlink() {
- return st_nlink.get();
- }
-
- public long rdev() {
- return st_rdev.get();
- }
-
- public long st_size() {
- return st_size.get();
- }
-
- public int uid() {
- return st_uid.get();
- }
-}
View
4 src/main/java/jnr/posix/FreeBSDPOSIX.java
@@ -39,8 +39,8 @@
super(libraryName, libc, handler);
}
- public BaseHeapFileStat allocateStat() {
- return new FreeBSDHeapFileStat(this);
+ public FileStat allocateStat() {
+ return new FreeBSDFileStat(this);
}
public static final PointerConverter PASSWD = new PointerConverter() {
View
127 src/main/java/jnr/posix/OpenBSDFileStat.java
@@ -0,0 +1,127 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ *
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+/**
+ * $Id: $
+ */
+
+package jnr.posix;
+
+import jnr.ffi.StructLayout;
+
+public final class OpenBSDFileStat extends BaseFileStat {
+ private static final class Layout extends StructLayout {
+
+ private Layout(jnr.ffi.Runtime runtime) {
+ super(runtime);
+ }
+
+ public final class time_t extends Signed32 {}
+ public final class dev_t extends Signed32 {}
+
+ public final dev_t st_dev = new dev_t();
+ public final Unsigned32 st_ino = new Unsigned32();
+ public final Unsigned32 st_mode = new Unsigned32();
+ public final Unsigned32 st_nlink = new Unsigned32();
+ public final Unsigned32 st_uid = new Unsigned32();
+ public final Unsigned32 st_gid = new Unsigned32();
+ public final dev_t st_rdev = new dev_t();
+ public final Signed32 st_lspare0 = new Signed32();
+ public final time_t st_atime = new time_t();
+ public final SignedLong st_atimensec = new SignedLong();
+ public final time_t st_mtime = new time_t();
+ public final SignedLong st_mtimensec = new SignedLong();
+ public final time_t st_ctime = new time_t();
+ public final SignedLong st_ctimensec = new SignedLong();
+ public final Signed64 st_size = new Signed64();
+ public final Signed64 st_blocks = new Signed64();
+ public final Unsigned32 st_blksize = new Unsigned32();
+ public final Unsigned32 st_flags = new Unsigned32();
+ public final Unsigned32 st_gen = new Unsigned32();
+ public final Signed32 st_lspare1 = new Signed32();
+ public final time_t st_birthtime = new time_t();
+ public final SignedLong st_birthtimensec = new SignedLong();
+ public final Signed64 st_qspare0 = new Signed64();
+ public final Signed64 st_qspare1 = new Signed64();
+ }
+ private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime());
+ public OpenBSDFileStat(NativePOSIX posix) {
+ super(posix, layout);
+ }
+
+ public long atime() {
+ return layout.st_atime.get(memory);
+ }
+
+ public long blocks() {
+ return layout.st_blocks.get(memory);
+ }
+
+ public long blockSize() {
+ return layout.st_blksize.get(memory);
+ }
+
+ public long ctime() {
+ return layout.st_ctime.get(memory);
+ }
+
+ public long dev() {
+ return layout.st_dev.get(memory);
+ }
+
+ public int gid() {
+ return (int) layout.st_gid.get(memory);
+ }
+
+ public long ino() {
+ return layout.st_ino.get(memory);
+ }
+
+ public int mode() {
+ return (int)(layout.st_mode.get(memory) & 0xffff);
+ }
+
+ public long mtime() {
+ return layout.st_mtime.get(memory);
+ }
+
+ public int nlink() {
+ return (int)layout.st_nlink.get(memory);
+ }
+
+ public long rdev() {
+ return layout.st_rdev.get(memory);
+ }
+
+ public long st_size() {
+ return layout.st_size.get(memory);
+ }
+
+ public int uid() {
+ return (int)layout.st_uid.get(memory);
+ }
+}
View
117 src/main/java/jnr/posix/OpenBSDHeapFileStat.java
@@ -1,117 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-/**
- * $Id: $
- */
-
-package jnr.posix;
-
-public final class OpenBSDHeapFileStat extends BaseHeapFileStat {
- public final class time_t extends Signed32 {}
- public final class dev_t extends Signed32 {}
-
- public final dev_t st_dev = new dev_t();
- public final Unsigned32 st_ino = new Unsigned32();
- public final Unsigned32 st_mode = new Unsigned32();
- public final Unsigned32 st_nlink = new Unsigned32();
- public final Unsigned32 st_uid = new Unsigned32();
- public final Unsigned32 st_gid = new Unsigned32();
- public final dev_t st_rdev = new dev_t();
- public final Signed32 st_lspare0 = new Signed32();
- public final time_t st_atime = new time_t();
- public final SignedLong st_atimensec = new SignedLong();
- public final time_t st_mtime = new time_t();
- public final SignedLong st_mtimensec = new SignedLong();
- public final time_t st_ctime = new time_t();
- public final SignedLong st_ctimensec = new SignedLong();
- public final Signed64 st_size = new Signed64();
- public final Signed64 st_blocks = new Signed64();
- public final Unsigned32 st_blksize = new Unsigned32();
- public final Unsigned32 st_flags = new Unsigned32();
- public final Unsigned32 st_gen = new Unsigned32();
- public final Signed32 st_lspare1 = new Signed32();
- public final time_t st_birthtime = new time_t();
- public final SignedLong st_birthtimensec = new SignedLong();
- public final Signed64 st_qspare0 = new Signed64();
- public final Signed64 st_qspare1 = new Signed64();
-
- public OpenBSDHeapFileStat(NativePOSIX posix) {
- super(posix);
- }
- public long atime() {
- return st_atime.get();
- }
-
- public long blocks() {
- return st_blocks.get();
- }
-
- public long blockSize() {
- return st_blksize.get();
- }
-
- public long ctime() {
- return st_ctime.get();
- }
-
- public long dev() {
- return st_dev.get();
- }
-
- public int gid() {
- return (int)st_gid.get();
- }
-
- public long ino() {
- return st_ino.get();
- }
-
- public int mode() {
- return (int)(st_mode.get() & 0xffff);
- }
-
- public long mtime() {
- return st_mtime.get();
- }
-
- public int nlink() {
- return (int)st_nlink.get();
- }
-
- public long rdev() {
- return st_rdev.get();
- }
-
- public long st_size() {
- return st_size.get();
- }
-
- public int uid() {
- return (int)st_uid.get();
- }
-}
View
4 src/main/java/jnr/posix/OpenBSDPOSIX.java
@@ -39,8 +39,8 @@
super(libraryName, libc, handler);
}
- public BaseHeapFileStat allocateStat() {
- return new OpenBSDHeapFileStat(this);
+ public FileStat allocateStat() {
+ return new OpenBSDFileStat(this);
}
public static final PointerConverter PASSWD = new PointerConverter() {
View
88 src/main/java/jnr/posix/WindowsFileStat.java
@@ -1,80 +1,90 @@
package jnr.posix;
-public class WindowsFileStat extends BaseHeapFileStat {
- public final Signed32 st_dev = new Signed32();
- public final Signed16 st_ino = new Signed16();
- public final Signed16 st_mode = new Signed16();
- public final Signed16 st_nlink = new Signed16();
- public final Signed16 st_uid = new Signed16();
- public final Signed16 st_gid = new Signed16();
- public final Signed32 st_rdev = new Signed32();
- public final Signed64 st_size = new Signed64();
- public final Signed64 st_atime = new Signed64();
- public final Signed64 st_mtime = new Signed64();
- public final Signed64 st_ctime = new Signed64();
+import jnr.ffi.StructLayout;
+
+public class WindowsFileStat extends BaseFileStat {
+ private static final class Layout extends StructLayout {
+
+ private Layout(jnr.ffi.Runtime runtime) {
+ super(runtime);
+ }
+
+ public final Signed32 st_dev = new Signed32();
+ public final Signed16 st_ino = new Signed16();
+ public final Signed16 st_mode = new Signed16();
+ public final Signed16 st_nlink = new Signed16();
+ public final Signed16 st_uid = new Signed16();
+ public final Signed16 st_gid = new Signed16();
+ public final Signed32 st_rdev = new Signed32();
+ public final Signed64 st_size = new Signed64();
+ public final Signed64 st_atime = new Signed64();
+ public final Signed64 st_mtime = new Signed64();
+ public final Signed64 st_ctime = new Signed64();
+ }
+ private static final Layout layout = new Layout(jnr.ffi.Runtime.getSystemRuntime());
public WindowsFileStat(NativePOSIX posix) {
- super(posix);
+ super(posix, layout);
}
public long atime() {
- return st_atime.get();
+ return layout.st_atime.get(memory);
}
public long blockSize() {
return 512;
}
public long blocks() {
- return (st_size.get() + 512 - 1) / 512;
+ return (layout.st_size.get(memory) + 512 - 1) / 512;
}
public long ctime() {
- return st_ctime.get();
+ return layout.st_ctime.get(memory);
}
public long dev() {
- return st_dev.get();
+ return layout.st_dev.get(memory);
}
public int gid() {
- return st_gid.get();
+ return layout.st_gid.get(memory);
}
public long ino() {
- return st_ino.get();
+ return layout.st_ino.get(memory);
}
public int mode() {
- return st_mode.get() & ~(S_IWGRP | S_IWOTH) & 0xffff;
+ return layout.st_mode.get(memory) & ~(S_IWGRP | S_IWOTH) & 0xffff;
}
public long mtime() {
- return st_mtime.get();
+ return layout.st_mtime.get(memory);
}
public int nlink() {
- return st_nlink.get();
+ return layout.st_nlink.get(memory);
}
public long rdev() {
- return st_rdev.get();
+ return layout.st_rdev.get(memory);
}
public long st_size() {
- return st_size.get();
+ return layout.st_size.get(memory);
}
public int uid() {
- return st_uid.get();
+ return layout.st_uid.get(memory);
}
- // FIXME: Implement
+ // FIXME: Implement
@Override
public boolean groupMember(int gid) {
return true;
}
-
+
@Override
public boolean isExecutable() {
if (isOwned()) return (mode() & S_IXUSR) != 0;
@@ -98,7 +108,7 @@ public boolean isExecutableReal() {
public boolean isOwned() {
return true;
}
-
+
// FIXME: Implement
@Override
public boolean isROwned() {
@@ -112,7 +122,7 @@ public boolean isReadable() {
return true;
}
-
+
@Override
public boolean isReadableReal() {
if (isROwned()) return (mode() & S_IRUSR) != 0;
@@ -142,16 +152,16 @@ public boolean isWritableReal() {
@Override
public java.lang.String toString() {
- return "st_dev: " + st_dev.get() +
+ return "st_dev: " + layout.st_dev.get(memory) +
", st_mode: " + Integer.toOctalString(mode()) +
- ", st_nlink: " + st_nlink.get() +
- ", st_rdev: " + st_rdev.get() +
- ", st_size: " + st_size.get() +
- ", st_uid: " + st_uid.get() +
- ", st_gid: " + st_gid.get() +
- ", st_atime: " + st_atime.get() +
- ", st_ctime: " + st_ctime.get() +
- ", st_mtime: " + st_mtime.get() +
- ", st_ino: " + st_ino.get();
+ ", layout.st_nlink: " + layout.st_nlink.get(memory) +
+ ", layout.st_rdev: " + layout.st_rdev.get(memory) +
+ ", layout.st_size: " + layout.st_size.get(memory) +
+ ", layout.st_uid: " + layout.st_uid.get(memory) +
+ ", layout.st_gid: " + layout.st_gid.get(memory) +
+ ", layout.st_atime: " + layout.st_atime.get(memory) +
+ ", layout.st_ctime: " + layout.st_ctime.get(memory) +
+ ", layout.st_mtime: " + layout.st_mtime.get(memory) +
+ ", layout.st_ino: " + layout.st_ino.get(memory);
}
}
View
2 src/main/java/jnr/posix/WindowsPOSIX.java
@@ -121,7 +121,7 @@
}
@Override
- public BaseHeapFileStat allocateStat() {
+ public FileStat allocateStat() {
return new WindowsFileStat(this);
}

0 comments on commit fd5aa60

Please sign in to comment.