Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_FILE_LINUX_H_ |
| 18 | #define ART_SRC_FILE_LINUX_H_ |
| 19 | |
| 20 | #include "file.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | class LinuxFile : public File { |
| 25 | public: |
| 26 | LinuxFile(const char* name, int fd, bool auto_close) : |
| 27 | File(name), fd_(fd), auto_close_(auto_close) {} |
| 28 | virtual ~LinuxFile(); |
| 29 | |
| 30 | virtual void Close(); |
| 31 | virtual bool IsClosed(); |
| 32 | |
| 33 | virtual int64_t Read(void* buffer, int64_t num_bytes); |
| 34 | virtual int64_t Write(const void* buffer, int64_t num_bytes); |
| 35 | |
Elliott Hughes | 2a2ff56 | 2012-01-06 18:07:59 -0800 | [diff] [blame] | 36 | virtual off_t Length(); |
| 37 | virtual off_t Position(); |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 38 | |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 39 | virtual int Fd() { |
| 40 | return fd_; |
| 41 | } |
| 42 | |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 43 | private: |
| 44 | static const int kClosedFd = -1; |
| 45 | |
| 46 | int fd_; |
| 47 | bool auto_close_; |
| 48 | }; |
| 49 | |
| 50 | } // namespace art |
| 51 | |
| 52 | #endif // ART_SRC_FILE_LINUX_H_ |