mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 04:50:54 +08:00
Added file info functions
This commit is contained in:
@@ -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)
|
bool hasEndingInsensitive(const std::string& fullString, const std::string& ending)
|
||||||
{
|
{
|
||||||
if (fullString.length() < ending.length())
|
if (fullString.length() < ending.length())
|
||||||
|
Reference in New Issue
Block a user