0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <acpi/acpi.h>
0011 #include "accommon.h"
0012 #include "acapps.h"
0013
0014 #define _COMPONENT ACPI_TOOLS
0015 ACPI_MODULE_NAME("cmfsize")
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 u32 cm_get_file_size(ACPI_FILE file)
0030 {
0031 long file_size;
0032 long current_offset;
0033 acpi_status status;
0034
0035
0036
0037 current_offset = ftell(file);
0038 if (current_offset < 0) {
0039 goto offset_error;
0040 }
0041
0042 status = fseek(file, 0, SEEK_END);
0043 if (ACPI_FAILURE(status)) {
0044 goto seek_error;
0045 }
0046
0047 file_size = ftell(file);
0048 if (file_size < 0) {
0049 goto offset_error;
0050 }
0051
0052
0053
0054 status = fseek(file, current_offset, SEEK_SET);
0055 if (ACPI_FAILURE(status)) {
0056 goto seek_error;
0057 }
0058
0059 return ((u32)file_size);
0060
0061 offset_error:
0062 fprintf(stderr, "Could not get file offset\n");
0063 return (ACPI_UINT32_MAX);
0064
0065 seek_error:
0066 fprintf(stderr, "Could not set file offset\n");
0067 return (ACPI_UINT32_MAX);
0068 }