blob: b5d6f3b4e0942c82537df4f6a27885a38e08a2e5 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 Carlstromdb4d5402011-08-09 12:18:28 -070016
17#ifndef ART_SRC_FILE_LINUX_H_
18#define ART_SRC_FILE_LINUX_H_
19
20#include "file.h"
21
22namespace art {
23
24class LinuxFile : public File {
25 public:
Ian Rogersca190662012-06-26 15:45:57 -070026 LinuxFile(const char* name, int fd, bool auto_close)
27 : File(name), fd_(fd), auto_close_(auto_close) {}
Brian Carlstromdb4d5402011-08-09 12:18:28 -070028 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 Hughes2a2ff562012-01-06 18:07:59 -080036 virtual off_t Length();
37 virtual off_t Position();
Brian Carlstromdb4d5402011-08-09 12:18:28 -070038
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070039 virtual int Fd() {
40 return fd_;
41 }
42
Brian Carlstromdb4d5402011-08-09 12:18:28 -070043 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_