本文整理汇总了C++中GetFileTime函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFileTime函数的具体用法?C++ GetFileTime怎么用?C++ GetFileTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFileTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLastWriteTimeForDirectory
FileWriteTime GetLastWriteTimeForDirectory(const std::string& path) {
HANDLE handle = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
CHECK_HANDLE_ERRORS(handle);
FILETIME lastWriteTime;
CHECK_RETURN_ERRORS(GetFileTime(handle, NULL, NULL, &lastWriteTime));
CHECK_RETURN_ERRORS(CloseHandle(handle));
FileWriteTime result;
result.lowDateTime = lastWriteTime.dwLowDateTime;
result.highDateTime = lastWriteTime.dwHighDateTime;
return result;
}
示例2: KG_PROCESS_ERROR
BOOL KSceneSettingPageRegionSplit::IsFileChanged( LPCTSTR lpPath, FILETIME OldFileTime )
{
FILETIME NewFileTime;
KG_PROCESS_ERROR(GetFileTime(lpPath, &NewFileTime));
if (NewFileTime.dwHighDateTime != OldFileTime.dwHighDateTime
|| NewFileTime.dwLowDateTime != OldFileTime.dwLowDateTime)
{
return TRUE;
}
Exit0:
return FALSE;
}
示例3: needCopyFileByDate
/// 更新時刻によってキャッシュする必要があるかどうか判断
static bool needCopyFileByDate( LPCTSTR filePath,
LPCTSTR cachePath )
{
FILETIME fileTime;
FILETIME cacheTime;
HANDLE fileHandle = CreateFile(filePath, 0, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 0, OPEN_EXISTING, 0, NULL);
HANDLE cacheHandle = CreateFile(cachePath, 0, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 0, OPEN_EXISTING, 0, NULL);
GetFileTime(fileHandle, NULL, NULL, &fileTime);
GetFileTime(cacheHandle, NULL, NULL, &cacheTime);
CloseHandle(fileHandle);
CloseHandle(cacheHandle);
if (CompareFileTime(&fileTime, &cacheTime)>0) {
return true;
}
return false;
}
示例4: My_GetFileTime
BOOL My_GetFileTime()
{
HANDLE hFile=NULL;
LPFILETIME lpCreationTime=NULL;
LPFILETIME lpLastAccessTime=NULL;
LPFILETIME lpLastWriteTime=NULL;
BOOL returnVal_Real = NULL;
BOOL returnVal_Intercepted = NULL;
DWORD error_Real = 0;
DWORD error_Intercepted = 0;
__try{
disableInterception();
returnVal_Real = GetFileTime (hFile,lpCreationTime,lpLastAccessTime,lpLastWriteTime);
error_Real = GetLastError();
enableInterception();
returnVal_Intercepted = GetFileTime (hFile,lpCreationTime,lpLastAccessTime,lpLastWriteTime);
error_Intercepted = GetLastError();
}__except(puts("in filter"), 1){puts("exception caught");}
return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
示例5: FindInCache
QDateTime AssetCache::LastModified(const QString &assetRef)
{
QString absolutePath = FindInCache(assetRef);
if (absolutePath.isEmpty())
return QDateTime();
#ifdef Q_WS_WIN
HANDLE fileHandle = (HANDLE)OpenFileHandle(absolutePath);
if (fileHandle == INVALID_HANDLE_VALUE)
{
LogError("AssetCache: Failed to open cache file to read last modified time: " + assetRef);
return QDateTime();
}
// Get last write time.
FILETIME fileTime;
BOOL success = GetFileTime(fileHandle, 0, 0, &fileTime); // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724320(v=VS.85).aspx
CloseHandle(fileHandle);
if (!success)
{
LogError("AssetCache: Failed to read cache file last modified time: " + assetRef);
return QDateTime();
}
// Convert to UTC.
SYSTEMTIME sysTime;
if (!FileTimeToSystemTime(&fileTime, &sysTime)) // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724280(v=VS.85).aspx
{
LogError("Win32 FileTimeToSystemTime failed for asset ref " + assetRef);
return QDateTime();
}
// Ignore msec
QDateTime dateTime;
dateTime.setTimeSpec(Qt::UTC);
dateTime.setDate(QDate((int)sysTime.wYear, (int)sysTime.wMonth, (int)sysTime.wDay));
dateTime.setTime(QTime((int)sysTime.wHour, (int)sysTime.wMinute, (int)sysTime.wSecond, 0));
return dateTime;
#else
QDateTime dateTime;
QString nativePath = QDir::toNativeSeparators(absolutePath);
struct stat fileStats;
if (stat(nativePath.toStdString().c_str(), &fileStats) == 0)
{
qint64 msecFromEpoch = (qint64)fileStats.st_mtime * 1000;
dateTime.setMSecsSinceEpoch(msecFromEpoch);
}
else
LogError("AssetCache: Failed to read cache file last modified time: " + assetRef);
return dateTime;
#endif
}
示例6: GetFileTime
void File::GetOpenFileTime(RarTime *ft)
{
#ifdef _WIN_32
FILETIME FileTime;
GetFileTime(hFile,NULL,NULL,&FileTime);
*ft=FileTime;
#endif
#if defined(_UNIX) || defined(_EMX)
struct stat st;
fstat(fileno(hFile),&st);
*ft=st.st_mtime;
#endif
}
示例7: loadShaderProgram
void loadShaderProgram(std::string sourcefile)
{
//printf("loading shader from %s\n", sourcefile.c_str());
g_shader.id = glCreateProgram();
refreshShaderProgram(sourcefile);
FILETIME create, access, write;
HANDLE fhandle = CreateFile(SHADER_SRC, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
GetFileTime(fhandle, &create, &access, &write);
ULONGLONG time = (((ULONGLONG) write.dwHighDateTime) << 32) + write.dwLowDateTime;
g_shader_modified = time;
CloseHandle(fhandle);
}
示例8: ChangeFileTime
// ////////////////////////////////////////////////////////////////////////////////
// @global 修改文件时间
//
void ChangeFileTime(const char *filename, unsigned long dosdate, tm_unz tmu_date)
{
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
}
示例9: IsFileNew
bool IsFileNew(LPCTSTR oldfile, LPCTSTR newfile)
{
FILETIME lpCreationTime;
FILETIME lpLastAccessTime;
FILETIME lpLastWriteTime;
FILETIME lpLastWriteTime2;
HANDLE file = CreateFile(oldfile, GENERIC_READ, FILE_SHARE_READ
, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if(file == INVALID_HANDLE_VALUE)
return false;
if(!GetFileTime(file, &lpCreationTime, &lpLastAccessTime, &lpLastWriteTime)) {
CloseHandle(file);
return false;
}
CloseHandle(file);
file = CreateFile(newfile, GENERIC_READ, FILE_SHARE_READ
, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if(file == INVALID_HANDLE_VALUE)
return false;
if(!GetFileTime(file, &lpCreationTime, &lpLastAccessTime, &lpLastWriteTime2)) {
CloseHandle(file);
return false;
}
CloseHandle(file);
if(lpLastWriteTime2.dwHighDateTime > lpLastWriteTime.dwHighDateTime ||
lpLastWriteTime2.dwLowDateTime > lpLastWriteTime.dwLowDateTime)
return true;
return false;
}
示例10: change_file_date
int change_file_date(char *fname,unsigned long dosdate)
{
HANDLE hfile;
hfile=CreateFile(fname,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(hfile!=INVALID_HANDLE_VALUE){
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
GetFileTime(hfile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hfile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hfile);
return TRUE;
}
示例11: _dos_getftime
_WCRTLINK unsigned _dos_getftime( int hid, unsigned *date, unsigned *time )
{
FILETIME ctime, atime, wtime;
unsigned short d, t;
if( GetFileTime( __getOSHandle( hid ), &ctime, &atime, &wtime ) ) {
__MakeDOSDT( &wtime, &d, &t );
*date = d;
*time = t;
return( 0 );
}
return( __set_errno_nt_reterr() );
}
示例12: GetFileTime
unsigned long long Zipped::getFiletime(const MappedFile& item)
{
unsigned long long itemFiletime = 0;
HANDLE h = item.handle();
if (h != INVALID_HANDLE_VALUE)
{
filetime64_t write = {0ULL};
GetFileTime(h, 0 /*create*/, 0 /*access*/, &write.ft);
itemFiletime = write.ft64;
}
return itemFiletime;
}
示例13: GetFileTime
/**
this is not needed for bulk_extractor
*/
void File::GetOpenFileTime(RarTime *ft)
{ //We probably don't need to worry about this at all.
#ifdef _WIN_ALL
FILETIME FileTime;
GetFileTime(hFile,NULL,NULL,&FileTime);
*ft=FileTime;
#endif
#if defined(_UNIX) || defined(_EMX)
struct stat st;
fstat(fileno(hFile),&st);
*ft=st.st_mtime;
#endif
}
示例14: CreateFile
FILETIME* FileUtils::getFileTime(const std::string& fileName) {
WORD ret = -1;
HANDLE hFile = CreateFile(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,OPEN_EXISTING, 0, NULL);
if( hFile != INVALID_HANDLE_VALUE) {
FILETIME* ftWrite = new FILETIME();
// Retrieve the file times for the file.
if (GetFileTime(hFile, NULL, NULL, ftWrite)) {
return ftWrite;
}
CloseHandle(hFile);
}
return 0;
}
示例15: GetFileTime
BOOL ffplayer::SetPlayedTime(DWORD nTime)
{
DWORD FileTime = GetFileTime();
if (FileTime == 0)
{
m_seekTime = 0;
return false;
}
float fPos = (float) nTime / (float)FileTime;
SetPlayPos(fPos);
m_seekTime = nTime;
return true;
}