BPicture: Fix archive constructor.
[haiku.git] / src / kits / package / hpkg / AttributeDataReader.cpp
blob62911af8470d551362129f0dca0955d2cbfe0e9a
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>
11 #include <fs_attr.h>
14 namespace BPackageKit {
16 namespace BHPKG {
19 BAttributeDataReader::BAttributeDataReader(int fd, const char* attribute,
20 uint32 type)
22 fFD(fd),
23 fType(type),
24 fAttribute(attribute)
29 status_t
30 BAttributeDataReader::ReadData(off_t offset, void* buffer, size_t size)
32 ssize_t bytesRead = fs_read_attr(fFD, fAttribute, fType, offset, buffer,
33 size);
34 if (bytesRead < 0)
35 return errno;
36 return (size_t)bytesRead == size ? B_OK : B_ERROR;
40 } // namespace BHPKG
42 } // namespace BPackageKit