本文整理汇总了C++中CFileFind::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileFind::GetLength方法的具体用法?C++ CFileFind::GetLength怎么用?C++ CFileFind::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileFind
的用法示例。
在下文中一共展示了CFileFind::GetLength方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFilesToCopy
DWORD CSetupApp::GetFilesToCopy(CStringArray& files)
{
files.RemoveAll();
ULONGLONG total= 0;
CFileFind finder;
BOOL b= finder.FindFile(GetAppFolder() + _T("\\windirstat.*"));
while (b)
{
b= finder.FindNextFile();
if (finder.IsDirectory())
continue;
files.Add(finder.GetFilePath());
// Retrieve file size
total+= finder.GetLength();
}
finder.Close();
b= finder.FindFile(GetAppFolder() + _T("\\wdsr*.dll"));
while (b)
{
b= finder.FindNextFile();
if (finder.IsDirectory())
continue;
files.Add(finder.GetFilePath());
// Retrieve file size
total+= finder.GetLength();
}
finder.Close();
b= finder.FindFile(GetAppFolder() + _T("\\wdsh*.chm"));
while (b)
{
b= finder.FindNextFile();
if (finder.IsDirectory())
continue;
files.Add(finder.GetFilePath());
// Retrieve file size
total+= finder.GetLength();
}
finder.Close();
return (DWORD)total;
}
示例2: build_dir_tree
void CSoliDire::build_dir_tree(CTreeNode * & m_pRoot, CString basedir)
{
CTreeNode * root = m_pRoot;
CFileFind fnd;
CInode tmp(basedir, 1, 0);
root->set_inode(tmp);
if (basedir.Right(1) != "\\")
basedir += "\\";
BOOL bWorking = fnd.FindFile(basedir+"*.*");
for (int i=0; bWorking; i++)
{
bWorking = fnd.FindNextFile( );
if (fnd.IsDots())
{
i--;
continue;
}
m_DirTree->inc_filenum();
tmp = CInode(fnd.GetFilePath(), 0, fnd.GetLength());
if (i==0)
{
root->new_lchild();
root = root->get_lchild();
if (fnd.IsDirectory())
build_dir_tree(root, basedir+fnd.GetFileName());
else
root->set_inode(tmp);
}
else
{
root->new_rchild(tmp);
root = root->get_rchild();
if (fnd.IsDirectory())
build_dir_tree(root, basedir+fnd.GetFileName());
else
root->set_inode(tmp);
}
}
}
示例3: getInfo
//==============================================================================
bool CDiskItem::getInfo()
{
CFileFind finder;
BOOL bFound = finder.FindFile( getFullName() );
// TO DO: Only one file must be found!
if( bFound )
{
/*bNext=*/ finder.FindNextFile();
// (2) Get exact file name from the disk to exclude differences
// in capitalization
CDiskItem tmpDiskItem( finder.GetFilePath() );
CString strRoot = tmpDiskItem.getFullPath();
/* (3) Was, but was wrong with UNC:
CString strRoot = finder.GetRoot(); */
CDiskItem roottt( strRoot );
if( ! roottt.m_strName.IsEmpty() )
{
roottt.getInfo(); // Recursively
this->m_strDir = AddWithSlash( roottt.m_strDir, roottt.m_strName ) + L"\\";
}
this->m_strName = tmpDiskItem.m_strName;
// End of (2)
FILETIME ft;
// TO DO: Error processing?
/*if(! ??? */ finder.GetLastWriteTime( &ft );
m_LastWriteTime = ft;
m_size = finder.GetLength();
if( finder.IsDirectory() )
m_nType = DI_FOLDER;
else
m_nType = DI_FILE;
}
finder.Close();
return (bFound != 0);
}
示例4: Refresh
void CFileView::Refresh(char *dir)
{
// listview을 모두 지운다.
CListCtrl& list = GetListCtrl(); // !!!!!!!!!!!
list.DeleteAllItems();
SetCurrentDirectory( dir );
CFileFind f; BOOL b = f.FindFile("*.*");
while ( b )
{
b = f.FindNextFile();
if ( ! f.IsDirectory() && ! f.IsHidden() )
{
list.InsertItem(0, f.GetFileName(), 0);
CString msg;
msg.Format( "%d KB", (f.GetLength() / 1024) + 1 );
list.SetItemText(0, 1, msg );
}
}
}
示例5: GetFileList
void CLocalFolder::GetFileList( )
{
m_Childs.Reset( );
if ( m_pParent )
{
CString sPath;
CreatePath( this, sPath );
sPath = sPath + "*.*";
CFileFind Finder;
if ( !Finder.FindFile( sPath ) )
// Aucun fichier
return;
CLocalFileBase* pNew;
CLocalFolder* pFolder;
CLocalFile* pFile;
bool bNext = Finder.FindNextFile( ) ? true : false;
bool bOk = true;
while ( bOk )
{
pNew = NULL;
if ( Finder.IsDirectory( ) )
{
if ( !Finder.IsDots( ) )
{
pFolder = new CLocalFolder;
pNew = pFolder;
}
}
else
{
pFile = new CLocalFile;
pNew = pFile;
pFile->SetFileSize( Finder.GetLength( ) );
}
if ( pNew )
{
pNew->SetItemName( Finder.GetFileName( ) );
pNew->SetParent( this );
m_Childs.Add( pNew );
}
bOk = bNext;
if ( bOk )
bNext = Finder.FindNextFile( ) ? true : false;
}
m_iChildCount = m_Childs.GetSize( );
m_Childs.Sort( );
}
else
{
// Racine, on indique les répertoires
DWORD dwSize = ::GetLogicalDriveStrings( 0, NULL );
if ( !dwSize )
// Erreur....
return;
char* lpszDrives = new char[ dwSize + 1 ];
if ( dwSize < ::GetLogicalDriveStrings( dwSize, lpszDrives ) )
{
delete [] lpszDrives;
return;
}
char* lpszCurrent = lpszDrives;
m_Childs.Reset( );
CLocalFolder* pNew;
while ( strlen( lpszCurrent ) )
{
pNew = new CLocalFolder;
pNew->SetItemName( lpszCurrent );
lpszCurrent = lpszCurrent + strlen( lpszCurrent ) + 1;
m_Childs.Add( pNew );
pNew->SetParent( this );
}
delete [] lpszDrives;
m_iChildCount = m_Childs.GetSize( );
}
}
示例6: OnApply
BOOL CPPgDirectories::OnApply()
{
bool testtempdirchanged=false;
CString testincdirchanged = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR);
CString strIncomingDir;
GetDlgItemText(IDC_INCFILES, strIncomingDir);
MakeFoldername(strIncomingDir);
if (strIncomingDir.IsEmpty()){
strIncomingDir = thePrefs.GetDefaultDirectory(EMULE_INCOMINGDIR, true); // will create the directory here if it doesnt exists
SetDlgItemText(IDC_INCFILES, strIncomingDir);
}
else if (thePrefs.IsInstallationDirectory(strIncomingDir)){
AfxMessageBox(GetResString(IDS_WRN_INCFILE_RESERVED));
return FALSE;
}
else if (strIncomingDir.CompareNoCase(testincdirchanged) != 0 && strIncomingDir.CompareNoCase(thePrefs.GetDefaultDirectory(EMULE_INCOMINGDIR, false)) != 0){
// if the user chooses a non-default directory which already contains files, inform him that all those files
// will be shared
CFileFind ff;
CString strSearchPath;
strSearchPath.Format(_T("%s\\*"),strIncomingDir);
bool bEnd = !ff.FindFile(strSearchPath, 0);
bool bExistingFile = false;
while (!bEnd)
{
bEnd = !ff.FindNextFile();
if (ff.IsDirectory() || ff.IsDots() || ff.IsSystem() || ff.IsTemporary() || ff.GetLength()==0 || ff.GetLength()>MAX_EMULE_FILE_SIZE)
continue;
// ignore real LNK files
TCHAR szExt[_MAX_EXT];
_tsplitpath(ff.GetFileName(), NULL, NULL, NULL, szExt);
if (_tcsicmp(szExt, _T(".lnk")) == 0){
SHFILEINFO info;
if (SHGetFileInfo(ff.GetFilePath(), 0, &info, sizeof(info), SHGFI_ATTRIBUTES) && (info.dwAttributes & SFGAO_LINK)){
if (!thePrefs.GetResolveSharedShellLinks())
continue;
}
}
// ignore real THUMBS.DB files -- seems that lot of ppl have 'thumbs.db' files without the 'System' file attribute
if (ff.GetFileName().CompareNoCase(_T("thumbs.db")) == 0)
continue;
bExistingFile = true;
break;
}
if (bExistingFile
&& AfxMessageBox(GetResString(IDS_WRN_INCFILE_EXISTS), MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL)
{
return FALSE;
}
}
// checking specified tempdir(s)
CString strTempDir;
GetDlgItemText(IDC_TEMPFILES, strTempDir);
if (strTempDir.IsEmpty()){
strTempDir = thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true); // will create the directory here if it doesnt exists
SetDlgItemText(IDC_TEMPFILES, strTempDir);
}
int curPos=0;
CStringArray temptempfolders;
CString atmp=strTempDir.Tokenize(_T("|"), curPos);
while (!atmp.IsEmpty())
{
atmp.Trim();
if (!atmp.IsEmpty()) {
if (CompareDirectories(strIncomingDir, atmp)==0){
AfxMessageBox(GetResString(IDS_WRN_INCTEMP_SAME));
return FALSE;
}
if (thePrefs.IsInstallationDirectory(atmp)){
AfxMessageBox(GetResString(IDS_WRN_TEMPFILES_RESERVED));
return FALSE;
}
bool doubled=false;
for (int i=0;i<temptempfolders.GetCount();i++) // avoid double tempdirs
if (temptempfolders.GetAt(i).CompareNoCase(atmp)==0) {
doubled=true;
break;
}
if (!doubled) {
temptempfolders.Add(atmp);
if (thePrefs.tempdir.GetCount()>=temptempfolders.GetCount()) {
if( atmp.CompareNoCase(thePrefs.GetTempDir(temptempfolders.GetCount()-1))!=0 )
testtempdirchanged=true;
} else testtempdirchanged=true;
}
}
atmp = strTempDir.Tokenize(_T("|"), curPos);
}
if (temptempfolders.IsEmpty())
temptempfolders.Add(strTempDir = thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true));
if (temptempfolders.GetCount()!=thePrefs.tempdir.GetCount())
//.........这里部分代码省略.........
示例7: AddRecursiveFiles
void COpenFileDlg::AddRecursiveFiles( const CUString& strDir,int nItem )
{
CFileFind fileFind;
CUString pathAndFileType = strDir + CUString( _W( "\\*.*" ));
BOOL bStop=FALSE;
CUStringConvert strCnv;
// Iterate through the items in the listbox and populate the listconrol.
if (fileFind.FindFile( strCnv.ToT( pathAndFileType ) ) )
{
do
{
bStop=(fileFind.FindNextFile()==0);
CUString strFileName = CUString( fileFind.GetFileName() );
CUString strFileRoot = CUString( fileFind.GetRoot() );
CUString strFileType;
if ( TRUE == fileFind.IsDirectory() &&
FALSE == fileFind.IsDots() &&
TRUE == m_bRecursiveDir )
{
AddRecursiveFiles( strDir + CUString( _W( "\\" ) ) + strFileName, nItem );
}
if (fileFind.IsDirectory()==FALSE && fileFind.IsDots()==FALSE)
{
int nPos=strFileName.ReverseFind( _T( '.' ) );
if (nPos>0)
{
CUString strExt;
strExt = strFileName.Right(strFileName.GetLength()-nPos-1);
strFileType = strExt;
strExt.MakeUpper();
if ( CompareExt( strExt ) == TRUE )
{
CUString strFileSize;
CUString strFileDate;
CTime fileTime;
// Get the data/time stamp of this file
fileFind.GetLastWriteTime( fileTime );
// Format date time string
strFileDate.Format( _W( "%4d/%02d/%02d %02d:%02d" ), fileTime.GetYear(), fileTime.GetMonth(), fileTime.GetDay(), fileTime.GetHour(), fileTime.GetMinute() );
strFileSize.Format( _W( "%10.2f" ), fileFind.GetLength() / ( 1024.0 * 1024.0 ) );
CUStringConvert strCnv;
m_ctrlRequestedFiles.InsertItem( nItem, strCnv.ToT( strFileName ));
m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_TYPE, strCnv.ToT( strFileType ) );
m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_DATE ,strCnv.ToT( strFileDate ) );
m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_PATH, strCnv.ToT( strFileRoot ) );
m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_SIZE, strCnv.ToT( strFileSize ) );
m_ctrlRequestedFiles.SetItemData( nItem, (DWORD)fileTime.GetTime() );
nItem++;
}
}
}
} while (bStop!=TRUE);
}
m_bSortAscending=TRUE;
}
示例8: 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();
//-------------------------------------
}
示例9: Download
bool CFTP::Download(LPCTSTR strVideoName, LPCTSTR strDirectoryName)
{
ASSERT(m_pFtpConnection);
ASSERT(m_pFtpFileFind);
CInternetFile* pFile = 0;
CFileFind* pFinder = 0;
char* pBuffer = 0;
DWORD dwBytesRead = 0, dwBytesWritten, dwFileSize = 0;
__int64 i64TotalBytes = 0;
HANDLE hFile;
CString sFile, sRemoteFile;
CString sDirectory;
bool bReturn = true;
m_bAbort = false;
sDirectory = strDirectoryName;
if (sDirectory.GetAt(sDirectory.GetLength() - 1) == '\\')
sDirectory = sDirectory.Left(sDirectory.GetLength() - 1);
m_sVideoName = strVideoName;
sFile.Format("%s\\%s.mpg",sDirectory,m_sVideoName);
hFile = CreateFile(sFile,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
if (INVALID_HANDLE_VALUE == hFile)
return false;
try
{
sRemoteFile.Format("/r1/%s.mpg",m_sVideoName);
if (0 != (pFinder = GetFileInfo(sRemoteFile)))
dwFileSize = pFinder->GetLength();
pFile = m_pFtpConnection->OpenFile(sRemoteFile);
if (pFile)
{
//dwFileSize = pFile->GetLength();
pBuffer = new char[dwUPLOADBUFFERSIZE];
do
{
dwBytesRead = pFile->Read(pBuffer,dwUPLOADBUFFERSIZE);
//ReadFile(hFile,pBuffer,dwUPLOADBUFFERSIZE,&dwBytesRead,0);
if (dwBytesRead > 0)
{
WriteFile(hFile,pBuffer,dwBytesRead,&dwBytesWritten,0);
//pFile->Write(pBuffer,dwBytesRead);
i64TotalBytes += dwBytesRead;
OnDownloadProgress(sRemoteFile,i64TotalBytes,dwFileSize);
}
} while (dwBytesRead > 0 && !m_bAbort);
}
else
{
bReturn = false;
}
}
catch (CInternetException* e)
{
char strError[2048];
e->GetErrorMessage(strError,2048);
e->Delete();
bReturn = false;
}
if (pFile)
{
pFile->Close();
delete pFile;
pFile = 0;
}
if (pBuffer)
delete pBuffer;
CloseHandle(hFile);
return bReturn;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}