X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2Futil%2FSeekable.java;h=2bb195e3e3ae64893b93d9562a74b854d988aba1;hp=d49df6658bd9f920e592bc47f20ae4b06d28e62e;hb=b11e7c6c29f2b5f7b0828bf93eb741c4a30ec411;hpb=b9a61c0d0d94182340ac416abea42d07bc64baff diff --git a/src/org/ibex/nestedvm/util/Seekable.java b/src/org/ibex/nestedvm/util/Seekable.java index d49df66..2bb195e 100644 --- a/src/org/ibex/nestedvm/util/Seekable.java +++ b/src/org/ibex/nestedvm/util/Seekable.java @@ -1,5 +1,5 @@ // Copyright 2000-2005 the Contributors, as shown in the revision logs. -// Licensed under the Apache Public Source License 2.0 ("the License"). +// Licensed under the Apache License 2.0 ("the License"). // You may not use this file except in compliance with the License. package org.ibex.nestedvm.util; @@ -14,6 +14,9 @@ public abstract class Seekable { public abstract void close() throws IOException; public abstract int pos() throws IOException; + public void sync() throws IOException { + throw new IOException("sync not implemented for " + getClass()); + } public void resize(long length) throws IOException { throw new IOException("resize not implemented for " + getClass()); } @@ -84,16 +87,18 @@ public abstract class Seekable { public File(java.io.File file, boolean writable, boolean truncate) throws IOException { this.file = file; String mode = writable ? "rw" : "r"; - raf = truncate ? Platform.truncatedRandomAccessFile(file,mode) : new RandomAccessFile(file,mode); + raf = new RandomAccessFile(file,mode); + if (truncate) Platform.setFileLength(raf, 0); } public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); } public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; } + public void sync() throws IOException { raf.getFD().sync(); } public void seek(int pos) throws IOException{ raf.seek(pos); } public int pos() throws IOException { return (int) raf.getFilePointer(); } public int length() throws IOException { return (int)raf.length(); } public void close() throws IOException { raf.close(); } - public void resize(long length) throws IOException { raf.setLength(length); } + public void resize(long length) throws IOException { Platform.setFileLength(raf, (int)length); } public boolean equals(Object o) { return o != null && o instanceof File && file.equals(((File)o).file);