1 /* 2 * Copyright (C) 2015 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 */ 16 17 #ifndef FILE_H_ 18 19 #define FILE_H_ 20 21 #include <stdio.h> // for SEEK_SET 22 23 #include <media/stagefright/foundation/ABase.h> 24 #include <utils/Errors.h> 25 26 namespace android { 27 28 struct File { 29 File(); 30 File(const char *path, const char *mode); 31 32 ~File(); 33 34 status_t initCheck() const; 35 status_t setTo(const char *path, const char *mode); 36 void close(); 37 38 ssize_t read(void *data, size_t size); 39 ssize_t write(const void *data, size_t size); 40 41 off64_t seekTo(off64_t pos, int whence = SEEK_SET); 42 43 private: 44 status_t mInitCheck; 45 int mFd; 46 47 DISALLOW_EVIL_CONSTRUCTORS(File); 48 }; 49 50 } // namespace android 51 52 #endif // FILE_H_ 53