btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / kits / package / hpkg / FDDataReader.cpp
blob5a20fc4bb276062faac4eb84b3ef6a9e81d762fb
1 /*
2 * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <package/hpkg/DataReader.h>
9 #include <errno.h>
10 #include <unistd.h>
13 namespace BPackageKit {
15 namespace BHPKG {
18 BFDDataReader::BFDDataReader(int fd)
20 fFD(fd)
25 void
26 BFDDataReader::SetFD(int fd)
28 fFD = fd;
32 status_t
33 BFDDataReader::ReadData(off_t offset, void* buffer, size_t size)
35 ssize_t bytesRead = pread(fFD, buffer, size, offset);
36 if (bytesRead < 0)
37 return errno;
38 return (size_t)bytesRead == size ? B_OK : B_ERROR;
42 } // namespace BHPKG
44 } // namespace BPackageKit