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 7 8 9 #include <DataIO.h> 10 #include <Node.h> 11 #include <StorageDefs.h> 12 13 14 class BEntry; 15 16 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(); 26 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); 31 32 bool IsReadable() const; 33 bool IsWritable() const; 34 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); 39 40 virtual off_t Seek(off_t offset, uint32 seekMode); 41 virtual off_t Position() const; 42 43 virtual status_t SetSize(off_t size); 44 virtual status_t GetSize(off_t* size) const; 45 46 BFile &operator=(const BFile &file); 47 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(); 55 56 uint32 _reservedData[8]; 57 58 private: 59 int get_fd() const; 60 virtual void close_fd(); 61 62 private: 63 // The file's open mode. 64 uint32 fMode; 65 }; 66 67 #endif // _FILE_H 68