vfs: check userland buffers before reading them.
[haiku.git] / headers / os / storage / File.h
blobbd9947cc2254dedd361f610d8d4df7faac89626d
1 /*
2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _FILE_H
6 #define _FILE_H
9 #include <DataIO.h>
10 #include <Node.h>
11 #include <StorageDefs.h>
14 class BEntry;
17 class BFile : public BNode, public BPositionIO {
18 public:
19 BFile();
20 BFile(const BFile &file);
21 BFile(const entry_ref *ref, uint32 openMode);
22 BFile(const BEntry *entry, uint32 openMode);
23 BFile(const char *path, uint32 openMode);
24 BFile(const BDirectory *dir, const char *path, uint32 openMode);
25 virtual ~BFile();
27 status_t SetTo(const entry_ref *ref, uint32 openMode);
28 status_t SetTo(const BEntry *entry, uint32 openMode);
29 status_t SetTo(const char *path, uint32 openMode);
30 status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
32 bool IsReadable() const;
33 bool IsWritable() const;
35 virtual ssize_t Read(void *buffer, size_t size);
36 virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
37 virtual ssize_t Write(const void *buffer, size_t size);
38 virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
40 virtual off_t Seek(off_t offset, uint32 seekMode);
41 virtual off_t Position() const;
43 virtual status_t SetSize(off_t size);
44 virtual status_t GetSize(off_t* size) const;
46 BFile &operator=(const BFile &file);
48 private:
49 virtual void _PhiloFile1();
50 virtual void _PhiloFile2();
51 virtual void _PhiloFile3();
52 virtual void _PhiloFile4();
53 virtual void _PhiloFile5();
54 virtual void _PhiloFile6();
56 uint32 _reservedData[8];
58 private:
59 int get_fd() const;
60 virtual void close_fd();
62 private:
63 // The file's open mode.
64 uint32 fMode;
67 #endif // _FILE_H