From: bbahnsen Date: Thu, 26 Oct 2006 18:14:11 +0000 (+0000) Subject: Implement a filelength function for GCC. X-Git-Tag: edk2-stable201903~24029 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=fec763384826dd661c776bb6260ab2a8eda9bafa Implement a filelength function for GCC. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1847 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/CCode/Source/Common/CommonLib.c b/Tools/CCode/Source/Common/CommonLib.c index 4d1663a55a..618abd89bb 100644 --- a/Tools/CCode/Source/Common/CommonLib.c +++ b/Tools/CCode/Source/Common/CommonLib.c @@ -495,6 +495,14 @@ Returns: } #ifdef __GNUC__ + +size_t _filelength(FILE *file) +{ + struct stat stat_buf; + fstat(fileno(file), &stat_buf); + return stat_buf.st_size; +} + #ifndef __CYGWIN__ char *strlwr(char *s) { diff --git a/Tools/CCode/Source/Common/CommonLib.h b/Tools/CCode/Source/Common/CommonLib.h index 46f0cbace5..f6c29ef8a8 100644 --- a/Tools/CCode/Source/Common/CommonLib.h +++ b/Tools/CCode/Source/Common/CommonLib.h @@ -124,9 +124,13 @@ PrintGuidToBuffer ( #define ASSERT(x) assert(x) #ifdef __GNUC__ +#include +#include #define stricmp strcasecmp +#define _stricmp strcasecmp #define strnicmp strncasecmp #define strcmpi strcasecmp +size_t _filelength(FILE *file); #ifndef __CYGWIN__ char *strlwr(char *s); #endif diff --git a/Tools/CCode/Source/GenFvImage/GenFvImageLib.c b/Tools/CCode/Source/GenFvImage/GenFvImageLib.c index 888656ad5c..eb36663b8d 100644 --- a/Tools/CCode/Source/GenFvImage/GenFvImageLib.c +++ b/Tools/CCode/Source/GenFvImage/GenFvImageLib.c @@ -1617,15 +1617,7 @@ Returns: // // Get the file size // -#ifdef __GNUC__ - { - struct stat stat_buf; - fstat(fileno(NewFile), &stat_buf); - FileSize = stat_buf.st_size; - } -#else FileSize = _filelength (fileno (NewFile)); -#endif // // Read the file into a buffer