aslfileio.c (cfe30d02adda7c3b5c76156ac52d50d8cab325d9) | aslfileio.c (313a0c13efa638cf248e35eed49f36ec0a1a7f26) |
---|---|
1/****************************************************************************** 2 * 3 * Module Name: aslfileio - File I/O support 4 * 5 *****************************************************************************/ 6 7/* | 1/****************************************************************************** 2 * 3 * Module Name: aslfileio - File I/O support 4 * 5 *****************************************************************************/ 6 7/* |
8 * Copyright (C) 2000 - 2013, Intel Corp. | 8 * Copyright (C) 2000 - 2014, Intel Corp. |
9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. --- 20 unchanged lines hidden (view full) --- 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44#include <contrib/dev/acpica/compiler/aslcompiler.h> | 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. --- 20 unchanged lines hidden (view full) --- 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44#include <contrib/dev/acpica/compiler/aslcompiler.h> |
45#include <contrib/dev/acpica/include/acapps.h> |
|
45 46#define _COMPONENT ACPI_COMPILER 47 ACPI_MODULE_NAME ("aslfileio") 48 49 50/******************************************************************************* 51 * | 46 47#define _COMPONENT ACPI_COMPILER 48 ACPI_MODULE_NAME ("aslfileio") 49 50 51/******************************************************************************* 52 * |
52 * FUNCTION: AslAbort 53 * 54 * PARAMETERS: None 55 * 56 * RETURN: None 57 * 58 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious 59 * I/O errors. 60 * 61 ******************************************************************************/ 62 63void 64AslAbort ( 65 void) 66{ 67 68 AePrintErrorLog (ASL_FILE_STDERR); 69 if (Gbl_DebugFlag) 70 { 71 /* Print error summary to stdout also */ 72 73 AePrintErrorLog (ASL_FILE_STDOUT); 74 } 75 76 exit (1); 77} 78 79 80/******************************************************************************* 81 * | |
82 * FUNCTION: FlFileError 83 * 84 * PARAMETERS: FileId - Index into file info array 85 * ErrorId - Index into error message array 86 * 87 * RETURN: None 88 * 89 * DESCRIPTION: Decode errno to an error message and add the entire error --- 52 unchanged lines hidden (view full) --- 142/******************************************************************************* 143 * 144 * FUNCTION: FlGetFileSize 145 * 146 * PARAMETERS: FileId - Index into file info array 147 * 148 * RETURN: File Size 149 * | 53 * FUNCTION: FlFileError 54 * 55 * PARAMETERS: FileId - Index into file info array 56 * ErrorId - Index into error message array 57 * 58 * RETURN: None 59 * 60 * DESCRIPTION: Decode errno to an error message and add the entire error --- 52 unchanged lines hidden (view full) --- 113/******************************************************************************* 114 * 115 * FUNCTION: FlGetFileSize 116 * 117 * PARAMETERS: FileId - Index into file info array 118 * 119 * RETURN: File Size 120 * |
150 * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. | 121 * DESCRIPTION: Get current file size. Uses common seek-to-EOF function. 122 * File must be open. Aborts compiler on error. |
151 * 152 ******************************************************************************/ 153 154UINT32 155FlGetFileSize ( 156 UINT32 FileId) 157{ | 123 * 124 ******************************************************************************/ 125 126UINT32 127FlGetFileSize ( 128 UINT32 FileId) 129{ |
158 FILE *fp; | |
159 UINT32 FileSize; | 130 UINT32 FileSize; |
160 long Offset; | |
161 162 | 131 132 |
163 fp = Gbl_Files[FileId].Handle; 164 Offset = ftell (fp); | 133 FileSize = CmGetFileSize (Gbl_Files[FileId].Handle); 134 if (FileSize == ACPI_UINT32_MAX) 135 { 136 AslAbort(); 137 } |
165 | 138 |
166 fseek (fp, 0, SEEK_END); 167 FileSize = (UINT32) ftell (fp); 168 169 /* Restore file pointer */ 170 171 fseek (fp, Offset, SEEK_SET); | |
172 return (FileSize); 173} 174 175 176/******************************************************************************* 177 * 178 * FUNCTION: FlReadFile 179 * --- 167 unchanged lines hidden (view full) --- 347 348 Error = fclose (Gbl_Files[FileId].Handle); 349 if (Error) 350 { 351 FlFileError (FileId, ASL_MSG_CLOSE); 352 AslAbort (); 353 } 354 | 139 return (FileSize); 140} 141 142 143/******************************************************************************* 144 * 145 * FUNCTION: FlReadFile 146 * --- 167 unchanged lines hidden (view full) --- 314 315 Error = fclose (Gbl_Files[FileId].Handle); 316 if (Error) 317 { 318 FlFileError (FileId, ASL_MSG_CLOSE); 319 AslAbort (); 320 } 321 |
322 /* Do not clear/free the filename string */ 323 |
|
355 Gbl_Files[FileId].Handle = NULL; 356 return; 357} 358 359 360/******************************************************************************* 361 * 362 * FUNCTION: FlDeleteFile --- 31 unchanged lines hidden --- | 324 Gbl_Files[FileId].Handle = NULL; 325 return; 326} 327 328 329/******************************************************************************* 330 * 331 * FUNCTION: FlDeleteFile --- 31 unchanged lines hidden --- |