1 /*---------------------------------------------------------------------------* 2 * PFileImpl.h * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20 #ifndef __PFILEIMPL_H 21 #define __PFILEIMPL_H 22 23 24 25 #include "PFile.h" 26 #include "ptrd.h" 27 28 /** 29 * Portable file implementation. 30 */ 31 typedef struct PFileImpl_t 32 { 33 /** 34 * Interface functions that must be implemented. 35 */ 36 PFile Interface; 37 38 /** 39 * File name relative to the file-system path. 40 */ 41 LCHAR* filename; 42 43 /** 44 * True if file is in little endian format. 45 */ 46 ESR_BOOL littleEndian; 47 48 #ifdef USE_THREAD 49 /** 50 * Used to lock underlying file and provide atomic read/write operations. 51 */ 52 PtrdMonitor* lock; 53 #endif 54 } 55 PFileImpl; 56 57 /** 58 * Initializes variables declared in the superinterface. 59 * 60 * @param self PFile handle 61 * @param filename Name of the file 62 * @param littleEndian True if file is little-endian 63 * @return ESR_OUT_OF_MEMORY if system is out of memory 64 */ 65 PORTABLE_API ESR_ReturnCode PFileCreateImpl(PFile* self, const LCHAR* filename, ESR_BOOL littleEndian); 66 67 /** 68 * Default implementation. 69 */ 70 PORTABLE_API ESR_ReturnCode PFileDestroyImpl(PFile* self); 71 72 /** 73 * Default implementation. 74 */ 75 PORTABLE_API ESR_ReturnCode PFileGetFilenameImpl(PFile* self, LCHAR* filename, size_t* len); 76 77 /** 78 * Default implementation. 79 */ 80 PORTABLE_API ESR_ReturnCode PFileVfprintfImpl(PFile* self, int* result, const LCHAR* format, va_list args); 81 82 #endif /* __PFILEIMPL_H */ 83