Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2011-08-19 13:24:19 +0400
committerjfrijters <jfrijters>2011-08-19 13:24:19 +0400
commit4f49b8f6792a37b1c005a0e9b5fcc1879aa57d90 (patch)
treefd9853e54e94a7e703dcc83a6d1da358c2cce3e8 /openjdk/sun/nio/ch
parent883965d3543fe43ab960a7010188cd940e0bce9f (diff)
Fixed several append issues:
- FileChannelImpl.truncate() should not attempt to seek (would throw an exception) - FileDispatcherImpl.write() doesn't need to seek to EOF - FileDispatcherImpl.truncate() can't use fd.setLength() to truncate on append FileStream, so we open the file again to truncate it - NetFileSystemProvider.newFileChannel() should not set FileSystemRights.Write in append mode
Diffstat (limited to 'openjdk/sun/nio/ch')
-rw-r--r--openjdk/sun/nio/ch/FileChannelImpl.java4
-rw-r--r--openjdk/sun/nio/ch/FileDispatcherImpl.java12
2 files changed, 12 insertions, 4 deletions
diff --git a/openjdk/sun/nio/ch/FileChannelImpl.java b/openjdk/sun/nio/ch/FileChannelImpl.java
index 86049d69..160e1f54 100644
--- a/openjdk/sun/nio/ch/FileChannelImpl.java
+++ b/openjdk/sun/nio/ch/FileChannelImpl.java
@@ -343,6 +343,10 @@ public class FileChannelImpl
if (!isOpen())
return null;
+ // [IKVM] in append mode we're not allowed to seek backwards, but the atomic append will honor the new file size
+ if (append)
+ return this;
+
// set position to size if greater than size
if (p > size)
p = size;
diff --git a/openjdk/sun/nio/ch/FileDispatcherImpl.java b/openjdk/sun/nio/ch/FileDispatcherImpl.java
index e8d4a55b..9d836dfd 100644
--- a/openjdk/sun/nio/ch/FileDispatcherImpl.java
+++ b/openjdk/sun/nio/ch/FileDispatcherImpl.java
@@ -56,9 +56,6 @@ class FileDispatcherImpl extends FileDispatcher
}
int write(FileDescriptor fd, byte[] buf, int offset, int length) throws IOException {
- if (append) {
- fd.seek(fd.length());
- }
fd.writeBytes(buf, offset, length);
return length;
}
@@ -129,7 +126,14 @@ class FileDispatcherImpl extends FileDispatcher
}
int truncate(FileDescriptor fd, long size) throws IOException {
- fd.setLength(size);
+ if (append) {
+ // HACK in append mode we're not allowed to truncate, so we try to reopen the file and truncate that
+ try (FileOutputStream fos = new FileOutputStream(((FileStream)fd.getStream()).get_Name())) {
+ fos.getFD().setLength(size);
+ }
+ } else {
+ fd.setLength(size);
+ }
return 0;
}