xref: /haiku/headers/private/storage/FdIO.h (revision c55a06055f7c2523d188ce382806fe98eaa06bb6)
1*c55a0605SIngo Weinhold /*
2*c55a0605SIngo Weinhold  * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de.
3*c55a0605SIngo Weinhold  * Distributed under the terms of the MIT License.
4*c55a0605SIngo Weinhold  */
5*c55a0605SIngo Weinhold #ifndef _FD_IO_H_
6*c55a0605SIngo Weinhold #define _FD_IO_H_
7*c55a0605SIngo Weinhold 
8*c55a0605SIngo Weinhold 
9*c55a0605SIngo Weinhold #include <DataIO.h>
10*c55a0605SIngo Weinhold 
11*c55a0605SIngo Weinhold 
12*c55a0605SIngo Weinhold class BFdIO : public BPositionIO {
13*c55a0605SIngo Weinhold public:
14*c55a0605SIngo Weinhold 								BFdIO();
15*c55a0605SIngo Weinhold 								BFdIO(int fd, bool keepFd);
16*c55a0605SIngo Weinhold 	virtual						~BFdIO();
17*c55a0605SIngo Weinhold 
18*c55a0605SIngo Weinhold 			void				SetTo(int fd, bool keepFd);
19*c55a0605SIngo Weinhold 			void				Unset();
20*c55a0605SIngo Weinhold 
21*c55a0605SIngo Weinhold 	virtual	ssize_t				Read(void* buffer, size_t size);
22*c55a0605SIngo Weinhold 	virtual	ssize_t				Write(const void* buffer, size_t size);
23*c55a0605SIngo Weinhold 
24*c55a0605SIngo Weinhold 	virtual	ssize_t				ReadAt(off_t position, void* buffer,
25*c55a0605SIngo Weinhold 									size_t size);
26*c55a0605SIngo Weinhold 	virtual	ssize_t				WriteAt(off_t position, const void* buffer,
27*c55a0605SIngo Weinhold 									size_t size);
28*c55a0605SIngo Weinhold 
29*c55a0605SIngo Weinhold 	virtual	off_t				Seek(off_t position, uint32 seekMode);
30*c55a0605SIngo Weinhold 	virtual	off_t				Position() const;
31*c55a0605SIngo Weinhold 
32*c55a0605SIngo Weinhold 	virtual	status_t			SetSize(off_t size);
33*c55a0605SIngo Weinhold 	virtual	status_t			GetSize(off_t* _size) const;
34*c55a0605SIngo Weinhold 
35*c55a0605SIngo Weinhold private:
36*c55a0605SIngo Weinhold 								BFdIO(const BFdIO& other);
37*c55a0605SIngo Weinhold 			BFdIO&				operator=(const BFdIO& other);
38*c55a0605SIngo Weinhold 
39*c55a0605SIngo Weinhold private:
40*c55a0605SIngo Weinhold 			int					fFd;
41*c55a0605SIngo Weinhold 			bool				fOwnsFd;
42*c55a0605SIngo Weinhold };
43*c55a0605SIngo Weinhold 
44*c55a0605SIngo Weinhold 
45*c55a0605SIngo Weinhold #endif	// _FD_IO_H_
46