vfs: check userland buffers before reading them.
[haiku.git] / headers / private / storage / FileIO.h
blobf45b3d3bc7a0f7072c02435735df42fd762fa271
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
9 #include <stdio.h>
11 #include <DataIO.h>
14 class BFileIO : public BPositionIO {
15 public:
16 BFileIO(FILE* file,
17 bool takeOverOwnership = false);
18 virtual ~BFileIO();
20 virtual ssize_t Read(void *buffer, size_t size);
21 virtual ssize_t Write(const void *buffer, size_t size);
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);
28 virtual off_t Seek(off_t position, uint32 seekMode);
29 virtual off_t Position() const;
31 virtual status_t SetSize(off_t size);
32 virtual status_t GetSize(off_t* size) const;
34 private:
35 BFileIO(const BFileIO& other);
36 BFileIO& operator=(const BFileIO& other);
38 off_t _Seek(off_t position, uint32 seekMode) const;
40 private:
41 FILE* fFile;
42 bool fOwnsFile;
46 #endif // _FILE_IO_H