From 3debfe518679779c824e5f3740f0da2abbcca776 Mon Sep 17 00:00:00 2001 From: "Bruno G. Albuquerque" Date: Sat, 2 Feb 2008 17:38:55 +0000 Subject: [PATCH] ReadAt() should not change the file position. Tested under R5 and Zeta. This fixes bug #1200 (Received emails are missing attributes). I hope nothing relies on the previously broken behaviour. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23828 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 e1cc37f796..39bc89f981 100644 --- a/src/kits/storage/File.cpp +++ b/src/kits/storage/File.cpp @@ -358,7 +358,13 @@ BFile::ReadAt(off_t location, void *buffer, size_t size) return InitCheck(); if (location < 0) return B_BAD_VALUE; - return _kern_read(get_fd(), location, buffer, size); + + // ReadAt() is not supposed to move the current position on the file. + // Tested on BeOS R5 and Zeta. + ssize_t result = _kern_read(get_fd(), location, buffer, size); + Seek(-result, SEEK_CUR); // Resets file position. + + return result; } // Write