From 40da55c3adabc6ec197573972521410cedc88226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 2 Feb 2008 18:28:26 +0000 Subject: [PATCH] * the BeBook documents WriteAt() and Write() to differ analogous to ReadAt() and Read() with regards to the file position. Ie, WriteAt() is not supposed to modify the data pointer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23830 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/File.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/kits/storage/File.cpp b/src/kits/storage/File.cpp index 872890bdc9..c8c966ab8b 100644 --- a/src/kits/storage/File.cpp +++ b/src/kits/storage/File.cpp @@ -398,7 +398,13 @@ BFile::WriteAt(off_t location, const void *buffer, size_t size) return InitCheck(); if (location < 0) return B_BAD_VALUE; - return _kern_write(get_fd(), location, buffer, size); + + // WriteAt() is not supposed to move the current position on the file. + off_t curPos = Position(); // Cache current position. + ssize_t result = _kern_write(get_fd(), location, buffer, size); + Seek(curPos, SEEK_SET); // Resets file position. + + return result; } // Seek