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