mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 10:36:50 +08:00
Using explicity bit-length for longs to prevent overflow
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
@@ -94,7 +95,7 @@ namespace alpr
|
|||||||
AlprResults() {};
|
AlprResults() {};
|
||||||
virtual ~AlprResults() {};
|
virtual ~AlprResults() {};
|
||||||
|
|
||||||
long epoch_time;
|
int64_t epoch_time;
|
||||||
int img_width;
|
int img_width;
|
||||||
int img_height;
|
int img_height;
|
||||||
float total_processing_time_ms;
|
float total_processing_time_ms;
|
||||||
|
@@ -426,7 +426,7 @@ namespace alpr
|
|||||||
cJSON* root = cJSON_Parse(json.c_str());
|
cJSON* root = cJSON_Parse(json.c_str());
|
||||||
|
|
||||||
int version = cJSON_GetObjectItem(root, "version")->valueint;
|
int version = cJSON_GetObjectItem(root, "version")->valueint;
|
||||||
allResults.epoch_time = (long) cJSON_GetObjectItem(root, "epoch_time")->valuedouble;
|
allResults.epoch_time = (int64_t) cJSON_GetObjectItem(root, "epoch_time")->valuedouble;
|
||||||
allResults.img_width = cJSON_GetObjectItem(root, "img_width")->valueint;
|
allResults.img_width = cJSON_GetObjectItem(root, "img_width")->valueint;
|
||||||
allResults.img_height = cJSON_GetObjectItem(root, "img_height")->valueint;
|
allResults.img_height = cJSON_GetObjectItem(root, "img_height")->valueint;
|
||||||
allResults.total_processing_time_ms = cJSON_GetObjectItem(root, "processing_time_ms")->valueint;
|
allResults.total_processing_time_ms = cJSON_GetObjectItem(root, "processing_time_ms")->valueint;
|
||||||
|
@@ -119,14 +119,14 @@ namespace alpr
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
// Stub out these functions on Windows. They're used for the daemon anyway, which isn't supported on Windows.
|
// Stub out these functions on Windows. They're used for the daemon anyway, which isn't supported on Windows.
|
||||||
|
|
||||||
long getFileSize(std::string filename) { return 0; }
|
int64_t getFileSize(std::string filename) { return 0; }
|
||||||
static int makeDir(char *path, mode_t mode) { return 0; }
|
static int makeDir(char *path, mode_t mode) { return 0; }
|
||||||
bool makePath(char* path, mode_t mode) { return true; }
|
bool makePath(char* path, mode_t mode) { return true; }
|
||||||
long getFileCreationTime(std::string filename) { return 0; }
|
int64_t getFileCreationTime(std::string filename) { return 0; }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
long getFileSize(std::string filename)
|
int64_t getFileSize(std::string filename)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
int rc = stat(filename.c_str(), &stat_buf);
|
int rc = stat(filename.c_str(), &stat_buf);
|
||||||
@@ -139,7 +139,7 @@ namespace alpr
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long getFileCreationTime(std::string filename)
|
int64_t getFileCreationTime(std::string filename)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
int rc = stat(filename.c_str(), &stat_buf);
|
int rc = stat(filename.c_str(), &stat_buf);
|
||||||
@@ -153,7 +153,7 @@ namespace alpr
|
|||||||
double milliseconds = (stat_buf.st_ctim.tv_sec * 1000) + (((double) stat_buf.st_ctim.tv_nsec) / 1000000.0);
|
double milliseconds = (stat_buf.st_ctim.tv_sec * 1000) + (((double) stat_buf.st_ctim.tv_nsec) / 1000000.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (long) milliseconds;
|
return (int64_t) milliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int makeDir(const char *path, mode_t mode)
|
static int makeDir(const char *path, mode_t mode)
|
||||||
|
@@ -31,8 +31,8 @@ namespace alpr
|
|||||||
|
|
||||||
std::string filenameWithoutExtension(std::string filename);
|
std::string filenameWithoutExtension(std::string filename);
|
||||||
|
|
||||||
long getFileSize(std::string filename);
|
int64_t getFileSize(std::string filename);
|
||||||
long getFileCreationTime(std::string filename);
|
int64_t getFileCreationTime(std::string filename);
|
||||||
|
|
||||||
bool DirectoryExists( const char* pzPath );
|
bool DirectoryExists( const char* pzPath );
|
||||||
bool fileExists( const char* pzPath );
|
bool fileExists( const char* pzPath );
|
||||||
|
Reference in New Issue
Block a user