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:
@@ -65,3 +65,5 @@ address_cache
|
|||||||
/_build/*
|
/_build/*
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
/out/*
|
/out/*
|
||||||
|
Obj/
|
||||||
|
Release/
|
||||||
|
|||||||
@@ -163,17 +163,21 @@ static long fsize(FILE *pFile)
|
|||||||
return (size);
|
return (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned bacfile_file_size(uint32_t object_instance)
|
BACNET_UNSIGNED_INTEGER bacfile_file_size(uint32_t object_instance)
|
||||||
{
|
{
|
||||||
char *pFilename = NULL;
|
char *pFilename = NULL;
|
||||||
FILE *pFile = NULL;
|
FILE *pFile = NULL;
|
||||||
unsigned file_size = 0;
|
long file_position = 0;
|
||||||
|
BACNET_UNSIGNED_INTEGER file_size = 0;
|
||||||
|
|
||||||
pFilename = bacfile_name(object_instance);
|
pFilename = bacfile_name(object_instance);
|
||||||
if (pFilename) {
|
if (pFilename) {
|
||||||
pFile = fopen(pFilename, "rb");
|
pFile = fopen(pFilename, "rb");
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
file_size = fsize(pFile);
|
file_position = fsize(pFile);
|
||||||
|
if (file_position >= 0) {
|
||||||
|
file_size = (BACNET_UNSIGNED_INTEGER)file_position;
|
||||||
|
}
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "bacnet/bacnet_stack_exports.h"
|
#include "bacnet/bacnet_stack_exports.h"
|
||||||
#include "bacnet/bacdef.h"
|
#include "bacnet/bacdef.h"
|
||||||
#include "bacnet/bacenum.h"
|
#include "bacnet/bacenum.h"
|
||||||
|
#include "bacnet/bacint.h"
|
||||||
#include "bacnet/apdu.h"
|
#include "bacnet/apdu.h"
|
||||||
#include "bacnet/arf.h"
|
#include "bacnet/arf.h"
|
||||||
#include "bacnet/awf.h"
|
#include "bacnet/awf.h"
|
||||||
@@ -108,7 +109,7 @@ extern "C" {
|
|||||||
void bacfile_init(
|
void bacfile_init(
|
||||||
void);
|
void);
|
||||||
BACNET_STACK_EXPORT
|
BACNET_STACK_EXPORT
|
||||||
uint32_t bacfile_file_size(
|
BACNET_UNSIGNED_INTEGER bacfile_file_size(
|
||||||
uint32_t instance);
|
uint32_t instance);
|
||||||
|
|
||||||
/* handling for read property service */
|
/* handling for read property service */
|
||||||
|
|||||||
Reference in New Issue
Block a user