1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef FILE_DEVICE_H 6 #define FILE_DEVICE_H 7 8 9 #include "BaseDevice.h" 10 11 12 namespace BPrivate { 13 14 15 class FileDevice : public BaseDevice { 16 public: 17 FileDevice(); 18 virtual ~FileDevice(); 19 20 status_t Init(const char* path); 21 22 virtual status_t InitDevice(); 23 virtual void UninitDevice(); 24 25 virtual void Removed(); 26 27 virtual bool HasSelect() const; 28 virtual bool HasDeselect() const; 29 virtual bool HasRead() const; 30 virtual bool HasWrite() const; 31 virtual bool HasIO() const; 32 33 virtual status_t Open(const char* path, int openMode, 34 void** _cookie); 35 virtual status_t Read(void* cookie, off_t pos, void* buffer, 36 size_t* _length); 37 virtual status_t Write(void* cookie, off_t pos, const void* buffer, 38 size_t* _length); 39 virtual status_t IO(void* cookie, io_request* request); 40 virtual status_t Control(void* cookie, int32 op, void* buffer, 41 size_t length); 42 virtual status_t Select(void* cookie, uint8 event, selectsync* sync); 43 virtual status_t Deselect(void* cookie, uint8 event, 44 selectsync* sync); 45 46 virtual status_t Close(void* cookie); 47 virtual status_t Free(void* cookie); 48 49 private: 50 struct Cookie; 51 52 private: 53 int fFD; 54 off_t fFileSize; 55 }; 56 57 58 } // namespace BPrivate 59 60 61 using BPrivate::FileDevice; 62 63 64 #endif // FILE_DEVICE_H 65