1 /* 2 * Copyright (C) 2005 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 #include <sys/types.h> 18 19 // 20 // Handy utility functions and portability code. 21 // 22 #ifndef _LIBS_ANDROID_FW_MISC_H 23 #define _LIBS_ANDROID_FW_MISC_H 24 25 namespace android { 26 27 /* 28 * Some utility functions for working with files. These could be made 29 * part of a "File" class. 30 */ 31 typedef enum FileType { 32 kFileTypeUnknown = 0, 33 kFileTypeNonexistent, // i.e. ENOENT 34 kFileTypeRegular, 35 kFileTypeDirectory, 36 kFileTypeCharDev, 37 kFileTypeBlockDev, 38 kFileTypeFifo, 39 kFileTypeSymlink, 40 kFileTypeSocket, 41 } FileType; 42 /* get the file's type; follows symlinks */ 43 FileType getFileType(const char* fileName); 44 /* get the file's modification date; returns -1 w/errno set on failure */ 45 time_t getFileModDate(const char* fileName); 46 /* same, but also returns -1 if the file has already been deleted */ 47 time_t getFileModDate(int fd); 48 49 // Check if |path| or |fd| resides on a readonly filesystem. 50 bool isReadonlyFilesystem(const char* path); 51 bool isReadonlyFilesystem(int fd); 52 53 }; // namespace android 54 55 #endif // _LIBS_ANDROID_FW_MISC_H 56