2009-11-13 16:45:49 +03:00
|
|
|
/*
|
2011-01-30 18:15:33 +03:00
|
|
|
* Copyright 2009,2011, Haiku, Inc.
|
2009-11-13 16:45:49 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 18:05:38 +03:00
|
|
|
#ifndef _PACKAGE__HPKG__DATA_READER_H_
|
|
|
|
#define _PACKAGE__HPKG__DATA_READER_H_
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
namespace BPackageKit {
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BHPKG {
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BDataReader {
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
virtual ~BDataReader();
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BFDDataReader : public BDataReader {
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
BFDDataReader(int fd);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fFD;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BAttributeDataReader : public BDataReader {
|
2009-11-15 11:39:45 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
BAttributeDataReader(int fd,
|
2009-11-15 11:39:45 +03:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BBufferDataReader : public BDataReader {
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
BBufferDataReader(const void* data, size_t size);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
const void* fData;
|
|
|
|
size_t fSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
} // namespace BHPKG
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
#endif // _PACKAGE__HPKG__DATA_READER_H_
|