Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 1 | // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_FILE_LINUX_H_ |
| 4 | #define ART_SRC_FILE_LINUX_H_ |
| 5 | |
| 6 | #include "file.h" |
| 7 | |
| 8 | namespace art { |
| 9 | |
| 10 | class LinuxFile : public File { |
| 11 | public: |
| 12 | LinuxFile(const char* name, int fd, bool auto_close) : |
| 13 | File(name), fd_(fd), auto_close_(auto_close) {} |
| 14 | virtual ~LinuxFile(); |
| 15 | |
| 16 | virtual void Close(); |
| 17 | virtual bool IsClosed(); |
| 18 | |
| 19 | virtual int64_t Read(void* buffer, int64_t num_bytes); |
| 20 | virtual int64_t Write(const void* buffer, int64_t num_bytes); |
| 21 | |
| 22 | virtual off_t Length(); |
| 23 | virtual off_t Position(); |
| 24 | |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 25 | virtual int Fd() { |
| 26 | return fd_; |
| 27 | } |
| 28 | |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 29 | private: |
| 30 | static const int kClosedFd = -1; |
| 31 | |
| 32 | int fd_; |
| 33 | bool auto_close_; |
| 34 | }; |
| 35 | |
| 36 | } // namespace art |
| 37 | |
| 38 | #endif // ART_SRC_FILE_LINUX_H_ |