1/* 2 * Copyright (C) 2011 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 ************************************************************************ 18 * @file M4OSA_FileReader.h 19 * @ingroup OSAL 20 * @brief File reader 21 * @note This file declares functions and types to read a file. 22 ************************************************************************ 23*/ 24 25 26#ifndef M4OSA_FILEREADER_H 27#define M4OSA_FILEREADER_H 28 29 30#include "M4OSA_Types.h" 31#include "M4OSA_Error.h" 32#include "M4OSA_FileCommon.h" 33#include "M4OSA_Memory.h" 34 35 36 37/** This enum defines the option ID to be used in M4OSA_FileReadGetOption() 38 and M4OSA_FileReadSetOption()*/ 39typedef enum M4OSA_FileReadOptionID 40{ 41 /** Get the file size (M4OSA_fpos*)*/ 42 M4OSA_kFileReadGetFileSize 43 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x01), 44 45 /** Get the file attributes (M4OSA_FileAttribute*)*/ 46 M4OSA_kFileReadGetFileAttribute 47 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x02), 48 49 /** Get the file URL, provided by the M4OSA_FileReadOpen (M4OSA_Char*)*/ 50 M4OSA_kFileReadGetURL 51 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x03), 52 53 /** Get the file position (M4OSA_fpos*)*/ 54 M4OSA_kFileReadGetFilePosition 55 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x04), 56 57 /** Check end of file: TRUE if the EOF has been reached, FALSE else 58 (M4OSA_Bool*)*/ 59 M4OSA_kFileReadIsEOF 60 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x05), 61 62 /** Check lock of file */ 63 M4OSA_kFileReadLockMode 64 = M4OSA_OPTION_ID_CREATE(M4_READWRITE, M4OSA_FILE_READER, 0x06) 65 66} M4OSA_FileReadOptionID; 67 68 69 70 71 72/** This structure stores the set of the function pointer to access to a 73 file in read mode*/ 74typedef struct 75{ 76 M4OSA_ERR (*openRead) (M4OSA_Context* context, 77 M4OSA_Void* fileDescriptor, 78 M4OSA_UInt32 fileModeAccess); 79 80 M4OSA_ERR (*readData) (M4OSA_Context context, 81 M4OSA_MemAddr8 buffer, 82 M4OSA_UInt32* size); 83 84 M4OSA_ERR (*seek) (M4OSA_Context context, 85 M4OSA_FileSeekAccessMode seekMode, 86 M4OSA_FilePosition* position); 87 88 M4OSA_ERR (*closeRead) (M4OSA_Context context); 89 90 M4OSA_ERR (*setOption) (M4OSA_Context context, 91 M4OSA_FileReadOptionID optionID, 92 M4OSA_DataOption optionValue); 93 94 M4OSA_ERR (*getOption) (M4OSA_Context context, 95 M4OSA_FileReadOptionID optionID, 96 M4OSA_DataOption *optionValue); 97} M4OSA_FileReadPointer; 98 99#ifdef __cplusplus 100extern "C" 101{ 102#endif 103 104M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadOpen (M4OSA_Context* context, 105 M4OSA_Void* fileDescriptor, 106 M4OSA_UInt32 fileModeAccess); 107 108M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadData (M4OSA_Context context, 109 M4OSA_MemAddr8 buffer, 110 M4OSA_UInt32* size); 111 112M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadSeek (M4OSA_Context context, 113 M4OSA_FileSeekAccessMode seekMode, 114 M4OSA_FilePosition* position); 115 116M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadClose (M4OSA_Context context); 117 118M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadGetOption (M4OSA_Context context, 119 M4OSA_FileReadOptionID optionID, 120 M4OSA_DataOption *optionValue); 121 122M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadSetOption (M4OSA_Context context, 123 M4OSA_FileReadOptionID optionID, 124 M4OSA_DataOption optionValue); 125 126#ifdef __cplusplus 127} 128#endif 129 130#endif /*M4OSA_FILEREADER_H*/ 131 132