Added AttributeDataReader, a DataReader implementation for attributes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34053 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
29af97ceac
commit
56270ee1c9
@ -10,6 +10,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <fs_attr.h>
|
||||
|
||||
|
||||
// #pragma mark - DataReader
|
||||
|
||||
@ -39,6 +41,30 @@ FDDataReader::ReadData(off_t offset, void* buffer, size_t size)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - AttributeDataReader
|
||||
|
||||
|
||||
AttributeDataReader::AttributeDataReader(int fd, const char* attribute,
|
||||
uint32 type)
|
||||
:
|
||||
fFD(fd),
|
||||
fType(type),
|
||||
fAttribute(attribute)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AttributeDataReader::ReadData(off_t offset, void* buffer, size_t size)
|
||||
{
|
||||
ssize_t bytesRead = fs_read_attr(fFD, fAttribute, fType, offset, buffer,
|
||||
size);
|
||||
if (bytesRead < 0)
|
||||
return errno;
|
||||
return (size_t)bytesRead == size ? B_OK : B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BufferDataReader
|
||||
|
||||
|
||||
|
@ -30,6 +30,21 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class AttributeDataReader : public DataReader {
|
||||
public:
|
||||
AttributeDataReader(int fd,
|
||||
const char* attribute, uint32 type);
|
||||
|
||||
virtual status_t ReadData(off_t offset, void* buffer,
|
||||
size_t size);
|
||||
|
||||
private:
|
||||
int fFD;
|
||||
uint32 fType;
|
||||
const char* fAttribute;
|
||||
};
|
||||
|
||||
|
||||
class BufferDataReader : public DataReader {
|
||||
public:
|
||||
BufferDataReader(const void* data, size_t size);
|
||||
|
Loading…
Reference in New Issue
Block a user