From 9389c6aa98c1fa90f403b583c3d2db4fe86a4ca9 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 5 Jan 2015 19:01:41 -0500 Subject: [PATCH] Fixes for Windows compilation --- src/openalpr/support/filesystem.cpp | 64 +++++++++++++++++------------ src/openalpr/support/filesystem.h | 1 + 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/openalpr/support/filesystem.cpp b/src/openalpr/support/filesystem.cpp index fc64c2f..70ff594 100644 --- a/src/openalpr/support/filesystem.cpp +++ b/src/openalpr/support/filesystem.cpp @@ -26,32 +26,6 @@ namespace alpr - long getFileSize(std::string filename) - { - struct stat stat_buf; - int rc = stat(filename.c_str(), &stat_buf); - //return rc == 0 ? stat_buf.st_size : -1; - - // 512 bytes is the standard block size - if (rc == 0) - return 512 * stat_buf.st_blocks; - - return -1; - } - - long getFileCreationTime(std::string filename) - { - struct stat stat_buf; - int rc = stat(filename.c_str(), &stat_buf); - - if (rc != 0) - return 0; - - double milliseconds = (stat_buf.st_ctim.tv_sec * 1000) + (((double) stat_buf.st_ctim.tv_nsec) / 1000000.0); - - return (long) milliseconds; - } - bool hasEndingInsensitive(const std::string& fullString, const std::string& ending) @@ -142,6 +116,42 @@ namespace alpr } + #ifdef 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; } + static int makeDir(char *path, mode_t mode) { return 0; } + bool makePath(char* path, mode_t mode) { return true; } + long getFileCreationTime(std::string filename) { return 0; } + + #else + + long getFileSize(std::string filename) + { + struct stat stat_buf; + int rc = stat(filename.c_str(), &stat_buf); + //return rc == 0 ? stat_buf.st_size : -1; + + // 512 bytes is the standard block size + if (rc == 0) + return 512 * stat_buf.st_blocks; + + return -1; + } + + long getFileCreationTime(std::string filename) + { + struct stat stat_buf; + int rc = stat(filename.c_str(), &stat_buf); + + if (rc != 0) + return 0; + + double milliseconds = (stat_buf.st_ctim.tv_sec * 1000) + (((double) stat_buf.st_ctim.tv_nsec) / 1000000.0); + + return (long) milliseconds; + } + static int makeDir(const char *path, mode_t mode) { struct stat st; @@ -195,4 +205,6 @@ namespace alpr return (status); } + + #endif } \ No newline at end of file diff --git a/src/openalpr/support/filesystem.h b/src/openalpr/support/filesystem.h index 1916f4d..7b0c65c 100644 --- a/src/openalpr/support/filesystem.h +++ b/src/openalpr/support/filesystem.h @@ -6,6 +6,7 @@ #include "windows/dirent.h" #include "windows/utils.h" #include "windows/unistd_partial.h" +typedef int mode_t; #else #include #include