xref: /haiku/headers/private/storage/FileIO.h (revision 220d04022750f40f8bac8f01fa551211e28d04f2)
1 /*
2  * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _FILE_IO_H
6 #define _FILE_IO_H
7 
8 
9 #include <stdio.h>
10 
11 #include <DataIO.h>
12 
13 
14 class BFileIO : public BPositionIO {
15 public:
16 								BFileIO(FILE* file,
17 									bool takeOverOwnership = false);
18 	virtual						~BFileIO();
19 
20 	virtual	ssize_t				Read(void *buffer, size_t size);
21 	virtual	ssize_t				Write(const void *buffer, size_t size);
22 
23 	virtual	ssize_t				ReadAt(off_t position, void *buffer,
24 									size_t size);
25 	virtual	ssize_t				WriteAt(off_t position, const void *buffer,
26 									size_t size);
27 
28 	virtual	off_t				Seek(off_t position, uint32 seekMode);
29 	virtual	off_t				Position() const;
30 
31 	virtual	status_t			SetSize(off_t size);
32 	virtual	status_t			GetSize(off_t* size) const;
33 
34 private:
35 								BFileIO(const BFileIO& other);
36 			BFileIO&			operator=(const BFileIO& other);
37 
38 			off_t				_Seek(off_t position, uint32 seekMode) const;
39 
40 private:
41 			FILE*				fFile;
42 			bool				fOwnsFile;
43 };
44 
45 
46 #endif	// _FILE_IO_H
47