Bugfix/file object file size type (#116)

* Fix file object example file size type

* Add include for definition of BACnet unsigned.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2020-09-03 22:02:49 -05:00
committed by GitHub
parent b872ee7859
commit 8a866b6754
3 changed files with 11 additions and 4 deletions
+7 -3
View File
@@ -163,17 +163,21 @@ static long fsize(FILE *pFile)
return (size);
}
unsigned bacfile_file_size(uint32_t object_instance)
BACNET_UNSIGNED_INTEGER bacfile_file_size(uint32_t object_instance)
{
char *pFilename = NULL;
FILE *pFile = NULL;
unsigned file_size = 0;
long file_position = 0;
BACNET_UNSIGNED_INTEGER file_size = 0;
pFilename = bacfile_name(object_instance);
if (pFilename) {
pFile = fopen(pFilename, "rb");
if (pFile) {
file_size = fsize(pFile);
file_position = fsize(pFile);
if (file_position >= 0) {
file_size = (BACNET_UNSIGNED_INTEGER)file_position;
}
fclose(pFile);
}
}