Fixes for Windows compilation

This commit is contained in:
Matt Hill
2015-01-05 19:01:41 -05:00
parent ca084bf5f3
commit 9389c6aa98
2 changed files with 39 additions and 26 deletions

View File

@@ -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) 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) static int makeDir(const char *path, mode_t mode)
{ {
struct stat st; struct stat st;
@@ -195,4 +205,6 @@ namespace alpr
return (status); return (status);
} }
#endif
} }

View File

@@ -6,6 +6,7 @@
#include "windows/dirent.h" #include "windows/dirent.h"
#include "windows/utils.h" #include "windows/utils.h"
#include "windows/unistd_partial.h" #include "windows/unistd_partial.h"
typedef int mode_t;
#else #else
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>