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_FileWriter.h 19 * @ingroup OSAL 20 * @brief File writer 21 * @note This file declares functions and types to write in a file. 22 ************************************************************************ 23 */ 24 25 26 #ifndef M4OSA_FILEWRITER_H 27 #define M4OSA_FILEWRITER_H 28 29 #include "M4OSA_Types.h" 30 #include "M4OSA_Error.h" 31 #include "M4OSA_FileCommon.h" 32 #include "M4OSA_Memory.h" 33 34 35 /** This enum defines the option ID to be used in M4OSA_FileWriteGetOption() 36 and M4OSA_FileWriteSetOption()*/ 37 typedef enum 38 { 39 /** Get the file URL, provided by the M4OSA_FileWriteOpen (M4OSA_Char*)*/ 40 M4OSA_kFileWriteGetURL 41 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_WRITER, 0x01), 42 43 /** Get the file attributes (M4OSA_FileAttribute*)*/ 44 M4OSA_kFileWriteGetAttribute 45 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_WRITER, 0x02), 46 47 /** Get the reader context for read & write file. (M4OSA_Context*)*/ 48 M4OSA_kFileWriteGetReaderContext 49 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_WRITER, 0x03), 50 51 M4OSA_kFileWriteGetFilePosition 52 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_WRITER, 0x04), 53 54 M4OSA_kFileWriteGetFileSize 55 = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_WRITER, 0x05), 56 57 58 M4OSA_kFileWriteLockMode 59 = M4OSA_OPTION_ID_CREATE(M4_READWRITE, M4OSA_FILE_WRITER, 0x06), 60 61 62 /** Check lock of file */ 63 M4OSA_kFileWriteDescMode 64 = M4OSA_OPTION_ID_CREATE(M4_READWRITE, M4OSA_FILE_WRITER, 0x07) 65 } M4OSA_FileWriteOptionID; 66 67 68 /** This structure stores the set of the function pointer to access to a file 69 in read mode*/ 70 typedef struct 71 { 72 M4OSA_ERR (*openWrite) (M4OSA_Context* context, 73 M4OSA_Void* fileDescriptor, 74 M4OSA_UInt32 fileModeAccess); 75 76 M4OSA_ERR (*writeData) (M4OSA_Context context, 77 M4OSA_MemAddr8 data, 78 M4OSA_UInt32 size); 79 80 M4OSA_ERR (*seek) (M4OSA_Context context, 81 M4OSA_FileSeekAccessMode seekMode, 82 M4OSA_FilePosition* position); 83 84 M4OSA_ERR (*Flush) (M4OSA_Context context); 85 M4OSA_ERR (*closeWrite) (M4OSA_Context context); 86 M4OSA_ERR (*setOption) (M4OSA_Context context, 87 M4OSA_OptionID optionID, 88 M4OSA_DataOption optionValue); 89 90 M4OSA_ERR (*getOption) (M4OSA_Context context, 91 M4OSA_OptionID optionID, 92 M4OSA_DataOption* optionValue); 93 } M4OSA_FileWriterPointer; 94 95 #ifdef __cplusplus 96 extern "C" 97 { 98 #endif 99 100 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteOpen (M4OSA_Context* context, 101 M4OSA_Void* fileDescriptor, 102 M4OSA_UInt32 fileModeAccess); 103 104 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteData (M4OSA_Context context, 105 M4OSA_MemAddr8 data, 106 M4OSA_UInt32 size); 107 108 /* Pierre Lebeaupin 2008/04/29: WARNING! the feature of file*Seek which returns 109 the position in the file (from the beginning) after the seek in the "position" 110 pointer has been found to be unreliably (or sometimes not at all) implemented 111 in some OSALs, so relying on it is strongly discouraged, unless you really want 112 to have a pizza evening. */ 113 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteSeek (M4OSA_Context context, 114 M4OSA_FileSeekAccessMode seekMode, 115 M4OSA_FilePosition* position); 116 117 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteClose (M4OSA_Context context); 118 119 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteFlush (M4OSA_Context context); 120 121 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteGetOption (M4OSA_Context context, 122 M4OSA_OptionID optionID, 123 M4OSA_DataOption* optionValue); 124 125 M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileWriteSetOption (M4OSA_Context context, 126 M4OSA_OptionID optionID, 127 M4OSA_DataOption optionValue); 128 129 #ifdef __cplusplus 130 } 131 #endif 132 133 134 #endif /*M4OSA_FILEWRITER_H*/ 135 136