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