1 /* 2 * Copyright 2008-2010, François Revol, revol@free.fr. All rights reserved. 3 * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef HANDLE_H 7 #define HANDLE_H 8 9 10 #include <boot/vfs.h> 11 12 13 #ifdef __cplusplus 14 15 class Handle : public ConsoleNode { 16 public: 17 Handle(int handle); 18 Handle(); 19 virtual ~Handle(); 20 21 void SetHandle(int handle); 22 23 virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize); 24 virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize); 25 26 virtual off_t Size() const; 27 28 protected: 29 int16 fHandle; 30 }; 31 32 /* character devices */ 33 class CharHandle : public Handle { 34 public: 35 CharHandle(int handle); 36 CharHandle(); 37 virtual ~CharHandle(); 38 39 virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize); 40 virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize); 41 42 protected: 43 }; 44 45 /* block devices */ 46 /* cf. devices.cpp */ 47 48 #endif /* __cplusplus */ 49 50 #endif /* HANDLE_H */ 51