Add private class BFdIO

Simple BPositionIO implementation using the POSIX API on a FD. In effect
similar to BFile, but more easily ported to kernel and boot loader (and
the FD is reusable).
This commit is contained in:
Ingo Weinhold
2014-07-12 15:40:21 +02:00
parent 8546c4160e
commit c55a06055f
5 changed files with 170 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
#include <../private/storage/FdIO.h>
+45
View File
@@ -0,0 +1,45 @@
/*
* Copyright 2014, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _FD_IO_H_
#define _FD_IO_H_
#include <DataIO.h>
class BFdIO : public BPositionIO {
public:
BFdIO();
BFdIO(int fd, bool keepFd);
virtual ~BFdIO();
void SetTo(int fd, bool keepFd);
void Unset();
virtual ssize_t Read(void* buffer, size_t size);
virtual ssize_t Write(const void* buffer, size_t size);
virtual ssize_t ReadAt(off_t position, void* buffer,
size_t size);
virtual ssize_t WriteAt(off_t position, const void* buffer,
size_t size);
virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
virtual status_t GetSize(off_t* _size) const;
private:
BFdIO(const BFdIO& other);
BFdIO& operator=(const BFdIO& other);
private:
int fFd;
bool fOwnsFd;
};
#endif // _FD_IO_H_