本文整理汇总了C++中CFileFind::GetLastAccessTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileFind::GetLastAccessTime方法的具体用法?C++ CFileFind::GetLastAccessTime怎么用?C++ CFileFind::GetLastAccessTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileFind
的用法示例。
在下文中一共展示了CFileFind::GetLastAccessTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteReceivedFiles
void DeleteReceivedFiles(CString csDir)
{
if(csDir.Find(_T("\\ReceivedFiles\\")) == -1)
return;
FIX_CSTRING_PATH(csDir);
CTime ctOld = CTime::GetCurrentTime();
CTime ctFile;
ctOld -= CTimeSpan(0, 0, 0, 1);
CFileFind Find;
CString csFindString;
csFindString.Format(_T("%s*.*"), csDir);
BOOL bFound = Find.FindFile(csFindString);
while(bFound)
{
bFound = Find.FindNextFile();
if(Find.IsDots())
continue;
if(Find.IsDirectory())
{
CString csDir(Find.GetFilePath());
DeleteReceivedFiles(csDir);
RemoveDirectory(csDir);
}
if(Find.GetLastAccessTime(ctFile))
{
//Delete the remote copied file if it has'nt been used for the last day
if(ctFile < ctOld)
{
DeleteFile(Find.GetFilePath());
}
}
else
{
DeleteFile(Find.GetFilePath());
}
}
}
示例2: SelectTreeViewFolder
//------------------------------------------------
// 파일의 리스트 및 각 파일에 대한 자세한 정보를
// 함께 저장하게 됨
// data.h파일에 해당 구조체를 선언한다.
//--------------------------------------------------
void CMyExplorerDoc::SelectTreeViewFolder(CString strFullName)
{
LIST_VIEW* pListView;
CFileFind ff;
// 사용자가 폴더를 선택할 때마다 파일 리스트를
// 새로 업데이트 해야 함
// 따라서 기존 정보를 모두 삭제한다.
if (m_pFileList != NULL)
RemoveAllFileList();
m_pFileList = new CObList;
SetCurrentPath(strFullName);
strFullName += "*.*";
if (ff.FindFile(strFullName) == TRUE)
{
BOOL bFlag = TRUE;
while(bFlag == TRUE)
{
bFlag = ff.FindNextFile();
// 디렉토리 , 도트파일이면 다시 찾음
if (ff.IsDirectory() || ff.IsDots())
continue;
// 파일 정보를 알아내서LIST_VIEW 구조체에
// 저장한 후
// 그것을 모두 m_pFileList에 저장한다.
pListView = new LIST_VIEW;
InitListViewStruct(pListView);
pListView->strName = ff.GetFileName();
pListView->strPath = ff.GetFilePath();
CString strName = pListView->strName;
CString strExt = ff.GetFileTitle();
int nNum = strName.GetLength() - strExt.GetLength();
if (nNum == 0)
strExt = "";
else
strExt = strName.Right(nNum - 1);
pListView->strKind = strExt + " 파일";
pListView->dwFileSize = ff.GetLength();
CTime time;
if (ff.GetCreationTime(time) == TRUE)
pListView->tCreateTime = time;
if (ff.GetLastAccessTime(time) == TRUE)
pListView->tLastAccessTime = time;
if (ff.GetLastWriteTime(time) == TRUE)
pListView->tLastWriteTime = time;
if (ff.IsHidden() == TRUE)
pListView->bIsHidden = TRUE;
if (ff.IsReadOnly() == TRUE)
pListView->bIsReadOnly = TRUE;
if (ff.IsArchived() == TRUE)
pListView->bIsArchived = TRUE;
if (ff.IsSystem() == TRUE)
pListView->bIsSystem = TRUE;
m_pFileList->AddTail((CObject*)pListView);
}
}
ff.Close();
//------------------------------
m_pExpListView->SetFileList();
//-------------------------------------
}
示例3: UpdateFolder
DWORD CCpDialog::UpdateFolder(LPCSTR strSrcFolder, LPCSTR strDstFolder, bool bIncludeSubFolders)
{
CString strSrcPath = strSrcFolder + CString("*.*");
DWORD dwFileCount = 0;
CFileFind FileFind;
BOOL bFound = FileFind.FindFile(strSrcPath);
while (bFound)
{
bFound = FileFind.FindNextFile();
if (FileFind.IsDots())
continue;
CString strSrcFilePath = FileFind.GetFilePath();
CString strSrcFileName = FileFind.GetFileName();
if (FileFind.IsDirectory())
{
if (!bIncludeSubFolders)
continue;
CString strNewDstFolder = CString(strDstFolder) + strSrcFileName + "\\";
bool bCreated = !!::CreateDirectory(strNewDstFolder, NULL);
if (bCreated)
dwFileCount++;
CString strNewSrcFolder = strSrcFilePath + "\\";
dwFileCount += UpdateFolder(strNewSrcFolder, strNewDstFolder);
continue;
}
FILETIME SrcCreationTime;
FILETIME SrcAccessedTime;
FILETIME SrcModfiedTime;
FileFind.GetCreationTime(&SrcCreationTime);
FileFind.GetLastAccessTime(&SrcAccessedTime);
FileFind.GetLastWriteTime(&SrcModfiedTime);
CString strDstFilePath = CString(strDstFolder) + strSrcFileName;
if (FileExists(strDstFilePath))
{
FILETIME DstCreationTime;
FILETIME DstAccessedTime;
FILETIME DstModfiedTime;
bool bOK = GetFileTimes(strDstFilePath, DstCreationTime, DstAccessedTime, DstModfiedTime);
if (CFileTime(SrcModfiedTime) <= CFileTime(DstModfiedTime))
continue;
DWORD dwFileAttributes = ::GetFileAttributes(strDstFilePath);
if (dwFileAttributes && FILE_ATTRIBUTE_READONLY)
::SetFileAttributes(strDstFilePath, dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
}
bool bCopied = !!::CopyFile(strSrcFilePath, strDstFilePath, false/*bFailIfExists*/);
if (bCopied)
{
dwFileCount++;
SetFileTimes(strDstFilePath, SrcCreationTime, SrcAccessedTime, SrcModfiedTime);
}
}
FileFind.Close();
return dwFileCount;
}
示例4: GetCacheStats
gbool GUrlCache::GetCacheStats(const char *directory, time_t &oldest,DWORD &spaceInUse, int &filesInUse)
{
CFileFind finder;
CString dir = directory;
// add separator
int l = dir.GetLength();
if (l == 0) return FALSE;
if ( !((dir[l-1] == '\\') || (dir[l-1] == '/'))) dir += '\\';
dir += "*.*";
CString path;
CTime creationTime((time_t)0);
CTime accessTime((time_t)0);
CTime writeTime((time_t)0);
// setup the find structure
BOOL bWorking = finder.FindFile(dir);
while (bWorking) { // for all entrys
if (stop) break;
bWorking = finder.FindNextFile();
path = finder.GetFilePath();
creationTime = (time_t)0;
accessTime = (time_t)0;
writeTime = (time_t)0;
BOOL ret=finder.GetCreationTime(creationTime);
finder.GetLastAccessTime(accessTime);
finder.GetLastWriteTime(writeTime);
time_t t = creationTime.GetTime();
if (accessTime.GetTime()>0) t = max(t,accessTime.GetTime());
if (finder.IsDots( )) { // ignore . ..
} else if (finder.IsDirectory( )) { // recursively step down
GetCacheStats(path,oldest,spaceInUse,filesInUse);
}
else {
DWORD length = finder.GetLength();
TRACE("F %s c %ld a %ld w %ld size %ld \n",(const char *) path, creationTime.GetTime(),accessTime.GetTime(),writeTime.GetTime(),length);
oldest = min(oldest,t);
filesInUse++;
spaceInUse += length;
}
}
finder.Close();
return TRUE;
}
示例5: RemoveFiles
// recursively remove a file branch
gbool GUrlCache::RemoveFiles(const char *directory,time_t olderThan)
{
CFileFind finder;
CString dir = directory;
// add separator
int l = dir.GetLength();
if (l == 0) return FALSE;
if ( !((dir[l-1] == '\\') || (dir[l-1] == '/'))) dir += '\\';
dir += "*.*";
CString path;
CTime creationTime((time_t)0);
CTime accessTime((time_t)0);
CTime writeTime((time_t)0);
// setup the find structure
BOOL bWorking = finder.FindFile(dir);
LONGLONG fileSum=0;
while (bWorking) { // for all entrys
if (stop) break;
bWorking = finder.FindNextFile();
path = finder.GetFilePath();
creationTime = (time_t)0;
accessTime = (time_t)0;
writeTime = (time_t)0;
BOOL ret=finder.GetCreationTime(creationTime);
finder.GetLastAccessTime(accessTime);
finder.GetLastWriteTime(writeTime);
time_t t = creationTime.GetTime();
// if (accessTime.GetTime()>0) t = max(t,accessTime.GetTime());
if (finder.IsDots( )) { // ignore . ..
} else if (finder.IsDirectory( )) { // recursively step down
RemoveFiles(path,olderThan);
RemoveDirectory(path);
}
else {
DWORD length = finder.GetLength();
TRACE("F %s c %ld a %ld w %ld size %ld \n",(const char *) path, creationTime.GetTime(),accessTime.GetTime(),writeTime.GetTime(),length);
if (olderThan >0 ) {
if (t < olderThan) {
if (RemoveFile(path))
fileSum += length;
}
} else {
if (RemoveFile(path))
fileSum += length;
}
}
}
finder.Close();
TRACE("%ld bytes deleted \n",(long) fileSum);
return TRUE;
}
示例6: AddFiles
// add files to list
gbool GFileSorter::AddFiles(const char *directory,time_t &maxFileTime,BOOL &stop)
{
CFileFind finder;
CString dir = directory;
// add separator
int l = dir.GetLength();
if (l == 0) return FALSE;
if ( !((dir[l-1] == '\\') || (dir[l-1] == '/'))) dir += '\\';
dir += "*.*";
CString path;
CTime creationTime((time_t)0);
CTime accessTime((time_t)0);
CTime writeTime((time_t)0);
// setup the find structure
BOOL bWorking = finder.FindFile(dir);
while (bWorking) { // for all entrys
if (stop) break;
bWorking = finder.FindNextFile();
path = finder.GetFilePath();
creationTime = (time_t)0;
accessTime = (time_t)0;
writeTime = (time_t)0;
BOOL ret=finder.GetCreationTime(creationTime);
finder.GetLastAccessTime(accessTime);
finder.GetLastWriteTime(writeTime);
time_t t = creationTime.GetTime();
if (writeTime.GetTime()>0) t = max(t,writeTime.GetTime()); // HG wg Kristof
if (accessTime.GetTime()>0) t = max(t,accessTime.GetTime());
if (finder.IsDots( )) { // ignore . ..
} else if (finder.IsDirectory( )) { // recursively step down
t=0; // we want to delete empty directories new 20.10.98
AddFiles(path,t,stop);
DWORD length = 0;
// to do get date of latest
TRACE("D %s c %ld a %ld w %ld size %ld \n",(const char *) path, creationTime.GetTime(),accessTime.GetTime(),writeTime.GetTime(),length);
// time is the max of the child time +1
GFSortEntry *e = new GFSortEntry(path,t+1,length,gtrue);
if (!e) break;
if (!Add(e)) break;
if (t>maxFileTime) maxFileTime = t;
}
else {
DWORD length = finder.GetLength(); // get length 64
fileSum += length;
TRACE("F %s c %ld a %ld w %ld size %ld \n",(const char *) path, creationTime.GetTime(),accessTime.GetTime(),writeTime.GetTime(),length);
GFSortEntry *e = new GFSortEntry(path,t,length);
if (t>maxFileTime) maxFileTime = t;
if (!e) break;
if (!Add(e)) break;
}
}
finder.Close();
//TRACE("%ld bytes \n",(long)fileSum);
return TRUE;
}