#include <iostream>
#include <sys/stat.h>
bool getFileInfo(const std::string &strPath, long long &lCreateTime,
long long &lModifyTime, long long &lAccessTime,
long &lFileLen)
{
struct _stat tmpInfo;
if (_stat(strPath.c_str(), &tmpInfo) != 0)
{
return false;
}
lCreateTime = tmpInfo.st_ctime;
lModifyTime = tmpInfo.st_mtime;
lAccessTime = tmpInfo.st_atime;
lFileLen = tmpInfo.st_size;
return true;
}
int main(int argc, char *argv[])
{
long long lCreateTime = 0;
long long lModifyTime = 0;
long long lAccessTime = 0;
long lFileLen = 0;
getFileInfo("d:\\1.dst", lCreateTime, lModifyTime, lAccessTime, lFileLen);
std::cout << lCreateTime << std::endl;
std::cout << lModifyTime << std::endl;
std::cout << lAccessTime << std::endl;
std::cout << lFileLen << std::endl;
return 0;
}
|