From 96b6616434e0c0b065e06a0d75e23729f7ae84cb Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 6 Dec 2014 15:08:30 -0500 Subject: [PATCH] Added file info functions --- src/openalpr/support/filesystem.cpp | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/openalpr/support/filesystem.cpp b/src/openalpr/support/filesystem.cpp index 8431220..593f7fe 100644 --- a/src/openalpr/support/filesystem.cpp +++ b/src/openalpr/support/filesystem.cpp @@ -24,6 +24,36 @@ 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) { if (fullString.length() < ending.length())