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:
@@ -10,6 +10,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <fs_attr.h>
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - DataReader
|
// #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
|
// #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 {
|
class BufferDataReader : public DataReader {
|
||||||
public:
|
public:
|
||||||
BufferDataReader(const void* data, size_t size);
|
BufferDataReader(const void* data, size_t size);
|
||||||
|
|||||||
Reference in New Issue
Block a user