本文整理汇总了C++中GetFileTime函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFileTime函数的具体用法?C++ GetFileTime怎么用?C++ GetFileTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFileTime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Twiebs,项目名称:Raptor,代码行数:12,代码来源:platform_windows.cpp
示例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;
}
开发者ID:viticm,项目名称:pap2,代码行数:12,代码来源:KSceneSettingPageRegionSplit.cpp
示例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;
}
开发者ID:yusukei,项目名称:CacheFS,代码行数:22,代码来源:mirror.cpp
示例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));
}
开发者ID:IFGHou,项目名称:Holodeck,代码行数:21,代码来源:GetFileTime.cpp
示例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
}
开发者ID:360degrees-fi,项目名称:tundra,代码行数:52,代码来源:AssetCache.cpp
示例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
}
开发者ID:chicken1337,项目名称:kx-audio-driver,代码行数:13,代码来源:file.cpp
示例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);
}
开发者ID:jhk2,项目名称:glsandbox,代码行数:13,代码来源:main.cpp
示例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);
}
开发者ID:sssooonnnggg,项目名称:LibSrn,代码行数:16,代码来源:ZipTools.cpp
示例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;
}
开发者ID:william0wang,项目名称:meditor,代码行数:39,代码来源:shared.cpp
示例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;
}
开发者ID:pinchyCZN,项目名称:win_installer,代码行数:13,代码来源:file_ops.c
示例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() );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:13,代码来源:gftimwnt.c
示例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;
}
开发者ID:thanhtphung,项目名称:cppware,代码行数:13,代码来源:Zipped-win.cpp
示例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
}
开发者ID:ajnelson,项目名称:bulk_extractor,代码行数:16,代码来源:file.cpp
示例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;
}
开发者ID:amecky,项目名称:diesel2D,代码行数:13,代码来源:FileUtils.cpp
示例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;
}
开发者ID:github188,项目名称:SPlayer,代码行数:14,代码来源:ffplayer.cpp
示例16: CreateFile
time_t FileSystemManager::getFileCreationTime(QString filePath)
{
HANDLE hFile = CreateFile((LPCTSTR) filePath.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile)
{
// Get the file modification time
FILETIME fileCreationTime;
GetFileTime(hFile, &fileCreationTime, NULL, NULL);
CloseHandle(hFile);
return fileTimeToUnixTime(fileCreationTime);
}
return 0;
}
开发者ID:DX94,项目名称:BumpTop,代码行数:14,代码来源:BT_FileSystemManager.cpp
示例17: GetFileTime
//---------------------------------------------------------------------------
bool __fastcall TFile::SetDosTime(DWORD t)
{
//DWORD dos = 0L;
FILETIME CT, LAT, LWT, NORMAL;
if( ! handle ) return false;
Error = ! GetFileTime(handle, &CT, &LAT, &LWT);
DosDateTimeToFileTime((WORD)(t>>16), (WORD)t, &NORMAL);
LocalFileTimeToFileTime(&NORMAL, &LWT);
Error = ! SetFileTime(handle, &CT, &LAT, &LWT);
if( Exceptions && Error ) throw 0;
return true;
}
开发者ID:MaxBelkov,项目名称:visualsyslog,代码行数:15,代码来源:File.cpp
示例18: CWE506_Embedded_Malicious_Code__w32_file_attrib_accessed_12_bad
void CWE506_Embedded_Malicious_Code__w32_file_attrib_accessed_12_bad()
{
if(globalReturnsTrueOrFalse())
{
{
FILETIME ftAccess;
ULONGLONG qwResult;
HANDLE hFile = INVALID_HANDLE_VALUE;
do
{
hFile = CreateFile(TEXT("badFile.txt"),
GENERIC_READ | GENERIC_WRITE, /* needed for SetFileTime to work properly */
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
break;
}
if (!GetFileTime(hFile,
NULL,
&ftAccess,
NULL))
{
break;
}
/* adapted from http://support.microsoft.com/kb/188768 */
qwResult = (((ULONGLONG) ftAccess.dwHighDateTime) << 32) + ftAccess.dwLowDateTime;
/* Subtract 10 days from real last accesssed date */
qwResult -= 10 * _DAY;
/* Copy result back into ftAccess */
ftAccess.dwLowDateTime = (DWORD)(qwResult & 0xFFFFFFFF);
ftAccess.dwHighDateTime = (DWORD)(qwResult >> 32);
/* FLAW: Modify the file's last accessed time */
SetFileTime(hFile,
(LPFILETIME)NULL,
&ftAccess,
(LPFILETIME)NULL);
}
while (0);
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
}
}
}
else
{
{
开发者ID:maurer,项目名称:tiamat,代码行数:50,代码来源:CWE506_Embedded_Malicious_Code__w32_file_attrib_accessed_12.c
示例19: DEBUG_VERIFY
void TFile::GetTimes( FILETIME* pCreationTime,
FILETIME* pLastAccessTime,
FILETIME* pLastWriteTime) const
{
DEBUG_VERIFY_ALLOCATION;
DEBUG_VERIFY(IsOpen());
if(!(m_flOpenFlags & FOF_READ))
INITIATE_FAILURE;
if(!GetFileTime(m_hFile, pCreationTime, pLastAccessTime, pLastWriteTime))
INITIATE_FAILURE;
}
开发者ID:tetratec,项目名称:runescape-classic-dump,代码行数:14,代码来源:file.cpp
示例20: DBGPRINT
//---------------------------------------------------------------------
// put a local file --> remote
bool Server::cmdPut(bstring const & localName, bstring const & remotePath, bool exists)
{
DBGPRINT(("put '%s' '%s' %b\r\n", localName.c_str(), remotePath.c_str(), exists));
bstring cmd = bstring(exists ? TEXT("reput \"") : TEXT("put \"")) + localName + TEXT("\" \"") + remotePath + TEXT("\"");
if (!doCommand(cmd))
return false;
FILETIME ft;
HANDLE hFile = CreateFile(localName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == (HANDLE)HFILE_ERROR)
return true; // copy succeeded
GetFileTime(hFile, 0, 0, &ft);
long fsHigh = 0;
long fsLow = SetFilePointer(hFile, 0, &fsHigh, FILE_END);
CloseHandle(hFile);
bstring chmod = TEXT("----");
if (defChMod.length() > 0 || exeChMod.length() > 0) {
chmod = defChMod;
size_t ldot = remotePath.find_last_of('.');
if (ldot != (size_t)-1) {
bstring x = remotePath.substr(ldot);
std::map<bstring, bstring>::iterator i = exeExtensions.find(x);
if (i != exeExtensions.end())
chmod = exeChMod;
}
if (chmod.length() > 0) {
cmd = bstring(TEXT("chmod ")) + chmod + TEXT(" \"") + remotePath + TEXT("\"");
doCommand(cmd);
}
}
// fake update the directory
insertFile(remotePath, &ft, fsLow, fsHigh, '-', chmod);
// we cannot set the file time
if (disableMtime)
return true;
// if setting the mtime failes, do not try it again
if (!this->cmdMtime(remotePath, &ft))
disableMtime = true;
// put already succeeded.
return true;
}
开发者ID:BackupTheBerlios,项目名称:sftp4tc-svn,代码行数:51,代码来源:server.cpp
注:本文中的GetFileTime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论