summaryrefslogtreecommitdiff
path: root/source/compiler/aslfileio.c
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2014-02-18 13:18:17 -0800
committerRobert Moore <Robert.Moore@intel.com>2014-02-18 13:18:17 -0800
commit18248469987f3c6e12ce546004ec6fd358301136 (patch)
treefc1d3347a64ef5b129b738b106965690226a70ad /source/compiler/aslfileio.c
parent0726969a64f449f74cc6e191ac979fe2b723c827 (diff)
downloadacpica-18248469987f3c6e12ce546004ec6fd358301136.tar.gz
ACPICA tools: Add common function to get file size.
Replaces 7 separate instances of this common function, with full exception handling. One new file, common/cmfsize.c
Diffstat (limited to 'source/compiler/aslfileio.c')
-rw-r--r--source/compiler/aslfileio.c72
1 files changed, 5 insertions, 67 deletions
diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c
index 50f15340d..ee84a1208 100644
--- a/source/compiler/aslfileio.c
+++ b/source/compiler/aslfileio.c
@@ -114,14 +114,11 @@
*****************************************************************************/
#include "aslcompiler.h"
+#include "acapps.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfileio")
-long
-UtGetFileSize (
- FILE *fp);
-
/*******************************************************************************
*
@@ -187,65 +184,6 @@ FlOpenFile (
/*******************************************************************************
*
- * FUNCTION: UtGetFileSize
- *
- * PARAMETERS: fp - Open file handle
- *
- * RETURN: File Size. -1 on error.
- *
- * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open.
- * TBD: This function should be used to replace other similar
- * functions in ACPICA.
- *
- ******************************************************************************/
-
-long
-UtGetFileSize (
- FILE *fp)
-{
- long FileSize;
- long CurrentOffset;
-
-
- CurrentOffset = ftell (fp);
- if (CurrentOffset < 0)
- {
- goto OffsetError;
- }
-
- if (fseek (fp, 0, SEEK_END))
- {
- goto SeekError;
- }
-
- FileSize = ftell (fp);
- if (FileSize < 0)
- {
- goto OffsetError;
- }
-
- /* Restore file pointer */
-
- if (fseek (fp, CurrentOffset, SEEK_SET))
- {
- goto SeekError;
- }
-
- return (FileSize);
-
-
-OffsetError:
- perror ("Could not get file offset");
- return (-1);
-
-SeekError:
- perror ("Could not seek file");
- return (-1);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: FlGetFileSize
*
* PARAMETERS: FileId - Index into file info array
@@ -261,16 +199,16 @@ UINT32
FlGetFileSize (
UINT32 FileId)
{
- long FileSize;
+ UINT32 FileSize;
- FileSize = UtGetFileSize (Gbl_Files[FileId].Handle);
- if (FileSize == -1)
+ FileSize = CmGetFileSize (Gbl_Files[FileId].Handle);
+ if (FileSize == ACPI_UINT32_MAX)
{
AslAbort();
}
- return ((UINT32) FileSize);
+ return (FileSize);
}