• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FindClose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FindClose函数的典型用法代码示例。如果您正苦于以下问题:C++ FindClose函数的具体用法?C++ FindClose怎么用?C++ FindClose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FindClose函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FindFirstFileW

/**
*           bIndex == 1     遍历指定文件夹并解压缩
*           数据升级Config因为包括黑白名单缓存,需特殊处理
*/
void CDownloadOperation::uncompressTraverse(IN LPWSTR path ,IN BYTE bIndex, IN OUT LPWSTR parentDirectory )
{
	USES_CONVERSION;
	WIN32_FIND_DATAW  fw;
	HANDLE hFind= FindFirstFileW(path,&fw);

	if(hFind == INVALID_HANDLE_VALUE)
		return ;

	WBRETURN bIsWBCab = NONE;

	do
	{
		if(wcscmp(fw.cFileName,L".") == 0 || wcscmp(fw.cFileName,L"..") == 0 || wcscmp(fw.cFileName,L".svn") == 0)
			continue;

		if(fw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		{
			if(bIndex == 1)
			{	

			}
		}
		else
		{
			if(bIndex == 1 && strstr(W2A(fw.cFileName),"cab") != NULL)
			{
				std::wstring newFile ;
				bool bIsSC = isSpecialCab(fw.cFileName);

				newFile = this->getAppDataPath();

				if( !bIsSC )
					newFile += BANKINFOPATHNOFIND;

				WBRETURN bWBCab = IsNewTBCacheFile(fw.cFileName);
				if( bWBCab != NONE)
					if( bWBCab != bIsWBCab && bIsWBCab != ALL )
					{
						if( bIsWBCab == NONE)
							bIsWBCab = bWBCab;
						else
							bIsWBCab = ALL;
					}
				

				std::wstring existingFile ;
				existingFile = getBankCachePath();
				existingFile += fw.cFileName;

				//没有通过验证的升级包不允许升级
				if( _UpdateMgr.isSafeFile((wchar_t *)existingFile.c_str() ) )
				{				
					moveFiles(fw.cFileName, true);	

					CCabExtract tt;
					if(tt.ExtractFile(existingFile.c_str(), newFile.c_str() ) )
						OutputDebugStringW(L"extractFile is OK!");
					else
					{
						moveFiles(fw.cFileName, false);
					}
				}
			}
		}
	}
	while( FindNextFile(hFind,&fw) );  

	this->UpdateWBFile(bIsWBCab);
	FindClose(hFind);
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:75,代码来源:DownloadOperation.cpp


示例2: dialogproc

BOOL CALLBACK dialogproc(HWND h,UINT m,WPARAM w,LPARAM l)
{
	switch (m) {
		case WM_COMMAND:
			switch (LOWORD(w)) {
				case IDCANCEL:
					DestroyWindow(h);
					break;
				case 10:
					{
						char file[MAX_PATH]="";
						ofn.lpstrFile=file;
						ofn.nMaxFile=MAX_PATH;
						if (GetOpenFileName(&ofn)) {
							BASS_StreamFree(chan); // free the old stream
							if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP))) {
								// it ain't playable
								MESS(10,WM_SETTEXT,0,"click here to open a file...");
								MESS(11,WM_SETTEXT,0,"");
								Error("Can't play the file");
								break;
							}
							MESS(10,WM_SETTEXT,0,file);
							{ // display the file type and length
								QWORD bytes=BASS_ChannelGetLength(chan,BASS_POS_BYTE);
								DWORD time=BASS_ChannelBytes2Seconds(chan,bytes);
								BASS_CHANNELINFO info;
								BASS_ChannelGetInfo(chan,&info);
								sprintf(file,"channel type = %x (%s)\nlength = %I64u (%u:%02u)",
									info.ctype,GetCTypeString(info.ctype,info.plugin),bytes,time/60,time%60);
								MESS(11,WM_SETTEXT,0,file);
								MESS(12,TBM_SETRANGE,1,MAKELONG(0,time)); // update scroller range
							}
							BASS_ChannelPlay(chan,FALSE);
						}
					}
					break;
			}
			break;

		case WM_HSCROLL:
			if (l && LOWORD(w)!=SB_THUMBPOSITION && LOWORD(w)!=SB_ENDSCROLL) { // set the position
				int pos=SendMessage((HWND)l,TBM_GETPOS,0,0);
				BASS_ChannelSetPosition(chan,BASS_ChannelSeconds2Bytes(chan,pos),BASS_POS_BYTE);
			}
			break;

		case WM_TIMER:
			MESS(12,TBM_SETPOS,1,(DWORD)BASS_ChannelBytes2Seconds(chan,BASS_ChannelGetPosition(chan,BASS_POS_BYTE))); // update position
			break;

		case WM_INITDIALOG:
			win=h;
			// initialize default output device
			if (!BASS_Init(-1,44100,0,win,NULL)) {
				Error("Can't initialize device");
				DestroyWindow(win);
				break;
			}
			// initialize file selector
			memset(&ofn,0,sizeof(ofn));
			ofn.lStructSize=sizeof(ofn);
			ofn.hwndOwner=h;
			ofn.Flags=OFN_HIDEREADONLY|OFN_EXPLORER;
			ofn.lpstrFilter=filter;
			memcpy(filter,"BASS built-in (*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif)\0*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif\0",88);
			{ // look for plugins (in the executable's directory)
				WIN32_FIND_DATA fd;
				HANDLE fh;
				char path[MAX_PATH],*fp=filter+88;
				GetModuleFileName(0,path,sizeof(path));
				strcpy(strrchr(path,'\\')+1,"bass*.dll");
				fh=FindFirstFile(path,&fd);
				if (fh!=INVALID_HANDLE_VALUE) {
					do {
						HPLUGIN plug;
						if (plug=BASS_PluginLoad(fd.cFileName,0)) { // plugin loaded...
							const BASS_PLUGININFO *pinfo=BASS_PluginGetInfo(plug); // get plugin info to add to the file selector filter...
							int a;
							for (a=0;a<pinfo->formatc;a++) {
								fp+=sprintf(fp,"%s (%s) - %s",pinfo->formats[a].name,pinfo->formats[a].exts,fd.cFileName)+1; // format description
								fp+=sprintf(fp,"%s",pinfo->formats[a].exts)+1; // extension filter
							}
							// add plugin to the list
							MESS(20,LB_ADDSTRING,0,fd.cFileName);
						}
					} while (FindNextFile(fh,&fd));
					FindClose(fh);
				}
				if (!MESS(20,LB_GETCOUNT,0,0)) // no plugins...
					MESS(20,LB_ADDSTRING,0,"no plugins - visit the BASS webpage to get some");
				memcpy(fp,"All files\0*.*\0\0",15);
			}
			SetTimer(h,0,500,0); // timer to update the position
			return 1;

		case WM_DESTROY:
			// "free" the output device and all plugins
			BASS_Free();
			BASS_PluginFree(0);
//.........这里部分代码省略.........
开发者ID:J2TeaM,项目名称:au3-boilerplate,代码行数:101,代码来源:plugins.c


示例3: RecursiveHandler

void RecursiveHandler(const char* startdir, const char* outputdir, char* command, int option )
{
	WIN32_FIND_DATA	findData;
	HANDLE			findHandle;
	CString			startdirDyn;

	startdirDyn		= startdir;
	startdirDyn		+= "\\*.*";
	findHandle		= FindFirstFile(LPCTSTR(startdirDyn), &findData );

	DEBUG_EXEC(printf("\ndir: %s", LPCTSTR(startdirDyn)));
	if( INVALID_HANDLE_VALUE != findHandle )
	{
		int count = 0;
		do
		{
			if( count > 1 )
			{
				CString	 subDirDyn;
				subDirDyn = startdir;
				subDirDyn += "\\";
				subDirDyn += findData.cFileName;
				CString	 outputDirDyn;
				outputDirDyn  = outputdir;
				outputDirDyn += "\\";
				outputDirDyn += subDirDyn;

				if( findData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
				{
					DEBUG_EXEC(printf("\ndir:	"));
					DEBUG_EXEC(printf("(%s)", findData.cFileName ));
					_mkdir(LPCTSTR(outputDirDyn)); DEBUG_EXEC(printf("\nmkdir: %s", LPCTSTR(outputDirDyn)));
					RecursiveHandler(LPCTSTR(subDirDyn), outputdir, command, option);

				}
				else
				{
					DEBUG_EXEC(printf("\nprocess: "));
					CString	 fileNameDyn;
					fileNameDyn = startdir;
					fileNameDyn += "\\";
					fileNameDyn += findData.cFileName;
					DEBUG_EXEC(printf("%s -> %s", LPCTSTR(fileNameDyn), LPCTSTR(outputDirDyn) ));
					char buffer[1024];
					switch(option)
					{
					case R_QUANTIZE:
						sprintf(buffer, "%s -q %s %s", command, LPCTSTR(fileNameDyn), LPCTSTR(outputDirDyn)  );
						DEBUG_EXEC(printf("\n%s",buffer));
						system(buffer);
						break;
					case R_QUANTIZE_ALL:
						sprintf(buffer, "%s -qa %s %s", command, LPCTSTR(fileNameDyn), LPCTSTR(outputDirDyn)  );
						DEBUG_EXEC(printf("\n%s",buffer));
						system(buffer);
						break;
					case R_DTX2TGA:
						char tempBuf[256], tempBuf2[256];
						memset(tempBuf, '\0', 256);
						memset(tempBuf2, '\0', 256);
						strncpy(tempBuf, fileNameDyn, strlen(fileNameDyn)-3);
						// printf("\n\n\n%s\n\n", tempBuf);
						sprintf(tempBuf2, "%stga", tempBuf);
						// printf("\n\n%s\n\n\n", tempBuf2);
						sprintf(buffer, "%s -dtx2tga %s %s", command, LPCTSTR(fileNameDyn), LPCTSTR(tempBuf2));
						DEBUG_EXEC(printf("\n%s",buffer));
						system(buffer);
						break;
					};
					// QuantizeAllhandler(LPCTSTR(fileNameDyn), LPCTSTR(outputDirDyn) );
				}
			}
			count++;
		} while( FindNextFile(findHandle,&findData ) );

		FindClose(findHandle);
	}
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:78,代码来源:dtxutil.cpp


示例4: main

int main (int argc, char* argv[]) {

	if (argc < 2) {
		printf("Usage:\n");
		printf("%s max_filename [manager [port]]\n",argv[0]);
		return 1;
	}

	//-- Come up with a temporary path for creating archives
	if (!ExpandEnvironmentStrings("%TEMP%",work_path,MAX_PATH)) {
		if (!ExpandEnvironmentStrings("%TMP%",work_path,MAX_PATH)) {
			if (!ExpandEnvironmentStrings("%HOMEPATH%",work_path,MAX_PATH))
				strcpy(work_path,"c:\\");
		}
	}

	if (work_path[strlen(work_path) - 1] != '\\')
		strcat(work_path,"\\");

	//-- Creates new manager access module instance
	MaxNetManager* manager = CreateManager();
	if (manager) {
		try {
			//-- Setup default manager port
			short port = DF_MGRPORT;
			//-- Placeholder for manager name
			char managername[MAX_PATH];
			//-- If we have a port defined, use it
			if (argc > 3)
				port = atoi(argv[3]);
			//-- If we have a host name (or ip address) for the manager, use it
			if (argc > 2)
				strcpy(managername,argv[2]);
			else {
				//-- Otherwise, find out who is the manager (if any)
				//   The API will broadcast a message looking for a
				//   manager using the given port. If a manager is
				//   found, its name/ip address will be placed in 
				//   "managername" below.
				if (!manager->FindManager(port,managername)) {
					printf("Could not find a Manager\n");
					DestroyManager(manager);
					return 1;
				}
			}
			//-- Connect to the manager
			manager->Connect(port,managername);
			//-- We're connected. Sumbmit Job(s)...
			WIN32_FIND_DATA find;
			HANDLE findhandle = FindFirstFile(argv[1],&find);
			if (findhandle != INVALID_HANDLE_VALUE) {
				char opath[MAX_PATH],npath[MAX_PATH];
				_splitpath(argv[1],opath,npath,0,0);
				strcat(opath,npath);
				if (opath[strlen(opath) - 1] != '\\')
					strcat(opath,"\\");
				do {
					strcpy(npath,opath);
					strcat(npath,find.cFileName);
					printf("Submitting %s...",find.cFileName);
					if (!assign_job(manager,npath))
						break;
					printf("\r%s Submitted successfully...\n",find.cFileName);
				} while (FindNextFile(findhandle,&find));
				FindClose(findhandle);
			}
			manager->Disconnect();
		//-- Exception Handler
		} catch (MaxNet* maxerr) {
			printf("\n%s (0x%08X)\n",maxerr->GetErrorText(),maxerr->GetError());
		}
		//-- Clean up manager instance
		DestroyManager(manager);
	}
	return 0;
}
开发者ID:2asoft,项目名称:xray,代码行数:76,代码来源:jobassign.cpp


示例5: _hx_std_sys_read_dir

/**
   sys_read_dir : string -> string list
   <doc>Return the content of a directory</doc>
**/
Array<String> _hx_std_sys_read_dir( String p )
{
   Array<String> result = Array_obj<String>::__new();

#if defined(NEKO_WINDOWS)
   const wchar_t *path = p.__WCStr();
   size_t len = wcslen(path);
   if (len>MAX_PATH)
      return null();

   WIN32_FIND_DATAW d;
   HANDLE handle;
  #if defined(HX_WINRT) && !defined(_XBOX_ONE)
   std::wstring tempWStr(path);
   std::string searchPath(tempWStr.begin(), tempWStr.end());
  #else
   wchar_t searchPath[ MAX_PATH + 4 ];
   memcpy(searchPath,path, len*sizeof(wchar_t));
  #endif


   if( len && path[len-1] != '/' && path[len-1] != '\\' )
      searchPath[len++] = '/';
   searchPath[len++] = '*';
   searchPath[len++] = '.';
   searchPath[len++] = '*';
   searchPath[len] = '\0';

   hx::EnterGCFreeZone();
  #if defined(HX_WINRT) && !defined(_XBOX_ONE)
   handle = FindFirstFileEx(searchPath.c_str(), FindExInfoStandard, &d, FindExSearchNameMatch, NULL, 0);
  #else
   handle = FindFirstFileW(searchPath,&d);
  #endif
   if( handle == INVALID_HANDLE_VALUE )
   {
      hx::ExitGCFreeZone();
      return null();
   }
   while( true )
   {
      // skip magic dirs
      if( d.cFileName[0] != '.' || (d.cFileName[1] != 0 && (d.cFileName[1] != '.' || d.cFileName[2] != 0)) )
      {
         hx::ExitGCFreeZone();
         result->push(String(d.cFileName));
         hx::EnterGCFreeZone();
      }
      if( !FindNextFileW(handle,&d) )
         break;
   }
   FindClose(handle);
#elif !defined(EPPC)
   const char *name = p.__s;
   hx::EnterGCFreeZone();
   DIR *d = opendir(name);
   if( d == NULL )
   {
      hx::ExitGCFreeZone();
      hx::Throw(HX_CSTRING("Invalid directory"));
   }
   while( true )
   {
      struct dirent *e = readdir(d);
      if( e == NULL )
         break;
      // skip magic dirs
      if( e->d_name[0] == '.' && (e->d_name[1] == 0 || (e->d_name[1] == '.' && e->d_name[2] == 0)) )
         continue;
      hx::ExitGCFreeZone();
      result->push( String(e->d_name) );
      hx::ExitGCFreeZone();
   }
   closedir(d);
#endif
   hx::ExitGCFreeZone();

   return result;
}
开发者ID:cunwaitaoshu,项目名称:hxcpp,代码行数:83,代码来源:Sys.cpp


示例6: orte_list_local_hnps


//.........这里部分代码省略.........
    
    if( ORTE_SUCCESS != (ret = opal_os_dirpath_access(headdir, 0) )) {
        /* it is okay not to find this as there may not be any
         * HNP's present, and we don't write our own session dir
         */
        if (ORTE_ERR_NOT_FOUND != ret) {
            ORTE_ERROR_LOG(ret);
        }
        goto cleanup;
    }
    
    /*
     * Open up the base directory so we can get a listing
     */
    if( NULL == (cur_dirp = opendir(headdir)) ) {
        goto cleanup;
    }
    /*
     * For each directory
     */
    while( NULL != (dir_entry = readdir(cur_dirp)) ) {
        
        /*
         * Skip the obvious
         */
        if( 0 == strncmp(dir_entry->d_name, ".", strlen(".")) ||
            0 == strncmp(dir_entry->d_name, "..", strlen("..")) ) {
            continue;
        }
        
        /*
         * See if a contact file exists in this directory and read it
         */
        contact_filename = opal_os_path( false, headdir,
                                         dir_entry->d_name, "contact.txt", NULL );
        
        hnp = OBJ_NEW(orte_hnp_contact_t);
        if (ORTE_SUCCESS == (ret = orte_read_hnp_contact_file(contact_filename, hnp, connect))) {
            opal_list_append(hnps, &(hnp->super));
        } else {
            OBJ_RELEASE(hnp);
        }
     }
#else
    /*
     * Open up the base directory so we can get a listing.
     *
     * On Windows if we want to parse the content of a directory the filename
     * should end with the "*". Otherwise we will only open the directory
     * structure (and not the content).
     */
    char *subdirs = opal_os_path(false, orte_process_info.tmpdir_base, orte_process_info.top_session_dir, "*", NULL);
    headdir = opal_os_path(false, orte_process_info.tmpdir_base, orte_process_info.top_session_dir, NULL);

    hFind = FindFirstFile( subdirs, &file_data );
    if( INVALID_HANDLE_VALUE == hFind ) {
        goto cleanup;
    }
    
    /*
     * For each directory
     */
    do {
        /*
         * Skip the obvious
         */
        if( 0 == strncmp(file_data.cFileName, ".", strlen(".")) ||
            0 == strncmp(file_data.cFileName, "..", strlen("..")) ) {
            continue;
        }
        
        /*
         * See if a contact file exists in this directory and read it
         */
        contact_filename = opal_os_path( false, headdir,
                                         file_data.cFileName, "contact.txt", NULL );
        
        hnp = OBJ_NEW(orte_hnp_contact_t);
        if (ORTE_SUCCESS == (ret = orte_read_hnp_contact_file(contact_filename, hnp, connect))) {
            opal_list_append(hnps, &(hnp->super));
        } else {
            OBJ_RELEASE(hnp);
        }
    } while( 0 != FindNextFile( hFind, &file_data ) );
    
#endif  /* !defined(__WINDOWS__) */
    
cleanup:
#ifndef __WINDOWS__
    if( NULL != cur_dirp )
        closedir(cur_dirp);
#else
    FindClose(hFind);
#endif  /* __WINDOWS__ */
    free(headdir);
    if( NULL != contact_filename)
        free(contact_filename);
    
    return (opal_list_is_empty(hnps) ? ORTE_ERR_NOT_FOUND : ORTE_SUCCESS);
}
开发者ID:hpc,项目名称:cce-mpi-openmpi-1.4.3,代码行数:101,代码来源:hnp_contact.c


示例7: VerifyOutputFileName

BOOL VerifyOutputFileName(char* filename)
{
	HANDLE hFileSearch = NULL;
	WIN32_FIND_DATA FindDataStruct;
	BOOL returnValue = FALSE;

	hFileSearch = FindFirstFile(filename, &FindDataStruct);

	if(hFileSearch != INVALID_HANDLE_VALUE)
	{
		BOOL userCancel = FALSE;
		OPENFILENAME saveFileName;
		char initialDir[MAX_PATH] = {0x00};
		char* slash = NULL;
		char finalFile[MAX_PATH] = {0x00};
		char defaultExtension[MAX_PATH] = {0x00};
		int fileStart = 0, fileExtensionStart = 0;

		strcpy(initialDir, filename );
		strcpy(finalFile, filename );

		slash = strrchr(initialDir, '\\');

		if(slash)
		{
			*slash = 0x00;
		}

		saveFileName.lStructSize=sizeof(saveFileName); 
		saveFileName.hwndOwner=NULL; 
	    saveFileName.hInstance=NULL; 
	    saveFileName.lpstrFilter=	"PGP Files (*.PGP, *.ASC)\0"
									"*.PGP;*.ASC\0"
									"All Files (*.*)\0"
									"*.*\0\0";
		saveFileName.lpstrCustomFilter=NULL; 
	    saveFileName.nMaxCustFilter=0; 
		saveFileName.nFilterIndex=1; 
  	    saveFileName.lpstrFile=finalFile; 
	    saveFileName.nMaxFile=MAX_PATH; 
	    saveFileName.lpstrFileTitle=NULL; 
		saveFileName.nMaxFileTitle=0; 
		saveFileName.lpstrInitialDir=initialDir; 
		saveFileName.lpstrTitle=NULL; 
		saveFileName.Flags= OFN_OVERWRITEPROMPT | 
							OFN_HIDEREADONLY | 
							OFN_NOREADONLYRETURN| 
							OFN_EXPLORER;
		saveFileName.nFileOffset=fileStart; 
		saveFileName.nFileExtension=fileExtensionStart; 
		saveFileName.lpstrDefExt=defaultExtension; 
		saveFileName.lCustData=(long)NULL; 
		saveFileName.lpfnHook=NULL;
		saveFileName.lpTemplateName=NULL; 

		returnValue = GetSaveFileName(&saveFileName);

		if(returnValue)
		{
			strcpy(filename, finalFile);
		}
		
		FindClose(hFileSearch);
	}
	else
	{
		returnValue =  TRUE;
	}


	return returnValue;

}
开发者ID:hackshields,项目名称:antivirus,代码行数:73,代码来源:SendMailToolbarWndProc.c


示例8: SetRedraw

void FolderTree::DisplayPath(const tstring &sPath, HTREEITEM hParent, bool bUseSetRedraw /* = true */)
{
	//CWaitCursor c;

	//Speed up the job by turning off redraw
	if (bUseSetRedraw)
		SetRedraw(false);

	//Remove all the items currently under hParent
	HTREEITEM hChild = GetChildItem(hParent);
	while (hChild)
	{
		DeleteItem(hChild);
		hChild = GetChildItem(hParent);
	}

	//Should we display the root folder
	if (m_bShowRootedFolder && (hParent == TVI_ROOT))
	{
		FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
		pItem->m_sFQPath = m_sRootFolder;
		pItem->m_sRelativePath = m_sRootFolder;
		m_hRootedFolder = InsertFileItem(TVI_ROOT, pItem, false, GetIconIndex(m_sRootFolder), GetSelIconIndex(m_sRootFolder), true);
		Expand(m_hRootedFolder, TVE_EXPAND);
		return;
	}

	//find all the directories underneath sPath
	int nDirectories = 0;
	
	tstring sFile;
	if (sPath[sPath.size()-1] != _T('\\'))
		sFile = sPath + _T("\\");
	else
		sFile = sPath;

	WIN32_FIND_DATA fData;
	HANDLE hFind;
	hFind = FindFirstFile((sFile + _T("*")).c_str(), &fData);

	if(hFind != INVALID_HANDLE_VALUE)

	{
		do
		{
			tstring filename = fData.cFileName;
			if((fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && 
				(filename != _T(".")) && (filename != _T("..")))
			{
				++nDirectories;
				tstring path = sFile + filename;

				TCHAR szPath[_MAX_PATH];
				TCHAR szFname[_MAX_FNAME];
				TCHAR szExt[_MAX_EXT];
				_tsplitpath(path.c_str(), NULL, NULL, szFname, szExt);
				_tmakepath(szPath, NULL, NULL, szFname, szExt);

				FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
				pItem->m_sFQPath = path;
				pItem->m_sRelativePath = szPath;
				InsertFileItem(hParent, pItem, m_bShowSharedUsingDifferentIcon && IsShared(path), GetIconIndex(path), GetSelIconIndex(path), true);
			}
		} while (FindNextFile(hFind, &fData));
	}

	FindClose(hFind);

	//Now sort the items we just added
	TVSORTCB tvsortcb;
	tvsortcb.hParent = hParent;
	tvsortcb.lpfnCompare = CompareByFilenameNoCase;
	tvsortcb.lParam = 0;
	SortChildrenCB(&tvsortcb);

	//We want to add them before sorting
	checkRemovedDirs(sFile, hParent);

	//If no items were added then remove the "+" indicator from hParent
	if(nDirectories == 0)
		SetHasPlusButton(hParent, FALSE);

	//Turn back on the redraw flag
	if(bUseSetRedraw)
		SetRedraw(true);
}
开发者ID:Nordanvind,项目名称:airgit,代码行数:86,代码来源:FolderTree.cpp


示例9: file_listclose

void DOSIOCALL file_listclose(FLISTH hdl) {

    FindClose(hdl);
}
开发者ID:rururutan,项目名称:np2s,代码行数:4,代码来源:dosio.cpp


示例10: strPath

int CMainFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu)
{
	CString         strPath(pszPath);
	CString         strPath2;
	CString         str;
	WIN32_FIND_DATA wfd;
	HANDLE          h;
	int             nPos = 0;
	int             nEndPos = 0;
	int             nNewEndPos = 0;
	int             nLastDir = 0;
	TCHAR           buf[INTERNET_MAX_PATH_LENGTH];
	CStringArray    astrFavorites;
	CStringArray    astrDirs;
	CMenu*          pSubMenu;

	// make sure there's a trailing backslash
	if(strPath[strPath.GetLength() - 1] != _T('\\'))
		strPath += _T('\\');
	strPath2 = strPath;
	strPath += "*.*";

	// now scan the directory, first for .URL files and then for subdirectories
	// that may also contain .URL files
	h = FindFirstFile(strPath, &wfd);
	if(h != INVALID_HANDLE_VALUE)
	{
		nEndPos = nStartPos;
		do
		{
			if((wfd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))==0)
			{
				str = wfd.cFileName;
				if(str.Right(4) == _T(".url"))
				{
					// an .URL file is formatted just like an .INI file, so we can
					// use GetPrivateProfileString() to get the information we want
					::GetPrivateProfileString(_T("InternetShortcut"), _T("URL"),
											  _T(""), buf, INTERNET_MAX_PATH_LENGTH,
											  strPath2 + str);
					str = str.Left(str.GetLength() - 4);

					// scan through the array and perform an insertion sort
					// to make sure the menu ends up in alphabetic order
					for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
					{
						if(str.CompareNoCase(astrFavorites[nPos]) < 0)
							break;
					}
					astrFavorites.InsertAt(nPos, str);
					m_astrFavoriteURLs.InsertAt(nPos, buf);
					++nEndPos;
				}
			}
		} while(FindNextFile(h, &wfd));
		FindClose(h);
		// Now add these items to the menu
		for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
		{
			pMenu->AppendMenu(MF_STRING | MF_ENABLED, 0xe00 + nPos, astrFavorites[nPos]);
		}


		// now that we've got all the .URL files, check the subdirectories for more
		nLastDir = 0;
		h = FindFirstFile(strPath, &wfd);
		ASSERT(h != INVALID_HANDLE_VALUE);
		do
		{
			if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				// ignore the current and parent directory entries
				if(lstrcmp(wfd.cFileName, _T(".")) == 0 || lstrcmp(wfd.cFileName, _T("..")) == 0)
					continue;

				for(nPos = 0 ; nPos < nLastDir ; ++nPos)
				{
					if(astrDirs[nPos].CompareNoCase(wfd.cFileName) > 0)
						break;
				}
				pSubMenu = new CMenu;
				pSubMenu->CreatePopupMenu();

				// call this function recursively.
				nNewEndPos = BuildFavoritesMenu(strPath2 + wfd.cFileName, nEndPos, pSubMenu);
				if(nNewEndPos != nEndPos)
				{
					// only intert a submenu if there are in fact .URL files in the subdirectory
					nEndPos = nNewEndPos;
					pMenu->InsertMenu(nPos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)pSubMenu->m_hMenu, wfd.cFileName);
					pSubMenu->Detach();
					astrDirs.InsertAt(nPos, wfd.cFileName);
					++nLastDir;
				}
				delete pSubMenu;
			}
		} while(FindNextFile(h, &wfd));
		FindClose(h);
	}
	return nEndPos;
//.........这里部分代码省略.........
开发者ID:ampu,项目名称:FeatherweightVirtualMachine,代码行数:101,代码来源:MainFrm.cpp


示例11: serve_cleantemp

int serve_cleantemp(int *clientSocket, http_message *message)

{

	int num_files = 0;

	int bytecount = 0;

	WIN32_FIND_DATAA ffd;



	HANDLE hFindALL = FindFirstFileA("C:\\Windows\\Temp\\*", &ffd);

	if (INVALID_HANDLE_VALUE != hFindALL)

	{

		do

		{

			if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))

			{

				char *file_ext = strrchr(ffd.cFileName, '.');

				if (file_ext && strcmp(file_ext, ".dat"))

				{

					DeleteFileA(ffd.cFileName);

					num_files++;



					if (num_files == 1)

					{

						const char http_header[] =	"HTTP/1.0 400 Deleted\r\n\r\n";

						bytecount += send(*clientSocket, http_header, strlen(http_header), 0);

					}

					

					char fname_del[MAX_PATH+2];

					int buflen = sprintf_s(fname_del, sizeof(fname_del), "%s\r\n", ffd.cFileName);

					if (buflen > 0)

						bytecount += send(*clientSocket, fname_del, buflen, 0);

				}

			}

		} while(FindNextFileA(hFindALL, &ffd) != 0);

	}



	FindClose(hFindALL);



	if (num_files > 0)

		return bytecount;

	else

	{

		// Send OK response

		const char http_response[] = "HTTP/1.0 200 OK\r\n\r\n200 OK";

		return send(*clientSocket, http_response, strlen(http_response), 0);

	}

}
开发者ID:uvbs,项目名称:deepsecurity,代码行数:89,代码来源:WebService.cpp


示例12: closedir

CoreExport void closedir(DIR * handle)
{
	FindClose(handle->find_handle);
	delete handle;
}
开发者ID:Canternet,项目名称:inspircd,代码行数:5,代码来源:inspircd_win32wrapper.cpp


示例13: ACTION_RecurseSearchDirectory

/* Recursively searches the directory dir for files that match the signature
 * sig, up to (depth + 1) levels deep.  That is, if depth is 0, it searches dir
 * (and only dir).  If depth is 1, searches dir and its immediate
 * subdirectories.
 * Assumes sig->File is not NULL.
 * Returns ERROR_SUCCESS on success (which may include non-critical errors),
 * something else on failures which should halt the install.
 */
static UINT ACTION_RecurseSearchDirectory(MSIPACKAGE *package, LPWSTR *appValue,
 MSISIGNATURE *sig, LPCWSTR dir, int depth)
{
    HANDLE hFind;
    WIN32_FIND_DATAW findData;
    UINT rc = ERROR_SUCCESS;
    size_t dirLen = lstrlenW(dir), fileLen = lstrlenW(sig->File);
    WCHAR subpath[MAX_PATH];
    WCHAR *buf;
    DWORD len;

    static const WCHAR starDotStarW[] = { '*','.','*',0 };

    TRACE("Searching directory %s for file %s, depth %d\n", debugstr_w(dir),
          debugstr_w(sig->File), depth);

    if (depth < 0)
        return ERROR_SUCCESS;

    *appValue = NULL;
    /* We need the buffer in both paths below, so go ahead and allocate it
     * here.  Add two because we might need to add a backslash if the dir name
     * isn't backslash-terminated.
     */
    len = dirLen + max(fileLen, strlenW(starDotStarW)) + 2;
    buf = msi_alloc(len * sizeof(WCHAR));
    if (!buf)
        return ERROR_OUTOFMEMORY;

    lstrcpyW(buf, dir);
    PathAddBackslashW(buf);
    lstrcatW(buf, sig->File);

    hFind = FindFirstFileW(buf, &findData);
    if (hFind != INVALID_HANDLE_VALUE)
    {
        if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
        {
            BOOL matches;

            rc = ACTION_FileMatchesSig(sig, &findData, buf, &matches);
            if (rc == ERROR_SUCCESS && matches)
            {
                TRACE("found file, returning %s\n", debugstr_w(buf));
                *appValue = buf;
            }
        }
        FindClose(hFind);
    }

    if (rc == ERROR_SUCCESS && !*appValue)
    {
        lstrcpyW(buf, dir);
        PathAddBackslashW(buf);
        lstrcatW(buf, starDotStarW);

        hFind = FindFirstFileW(buf, &findData);
        if (hFind != INVALID_HANDLE_VALUE)
        {
            if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
                strcmpW( findData.cFileName, szDot ) &&
                strcmpW( findData.cFileName, szDotDot ))
            {
                lstrcpyW(subpath, dir);
                PathAppendW(subpath, findData.cFileName);
                rc = ACTION_RecurseSearchDirectory(package, appValue, sig,
                                                   subpath, depth - 1);
            }

            while (rc == ERROR_SUCCESS && !*appValue &&
                   FindNextFileW(hFind, &findData) != 0)
            {
                if (!strcmpW( findData.cFileName, szDot ) ||
                    !strcmpW( findData.cFileName, szDotDot ))
                    continue;

                lstrcpyW(subpath, dir);
                PathAppendW(subpath, findData.cFileName);
                if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                    rc = ACTION_RecurseSearchDirectory(package, appValue,
                                                       sig, subpath, depth - 1);
            }

            FindClose(hFind);
        }
    }

    if (*appValue != buf)
        msi_free(buf);

    return rc;
}
开发者ID:GYGit,项目名称:reactos,代码行数:100,代码来源:appsearch.c


示例14: IncludeTrailingPathDelimiter


//.........这里部分代码省略.........

if (FileName == "") {  //ディレクトリ
	FileName = "*.*";
}
else{
	fParent = true;
}

ret = FindFirst(DirPath + FileName, faAnyFile, sr);

while (ret == 0) {

	if (sr.Name != "." && sr.Name != "..") {

		FilePath = DirPath + sr.Name;
		FileNameString = ExtractRelativePath(BasePath, FilePath);

		//-----------------------------------
		//ディレクトリ
		if (sr.Attr & faDirectory) {

			// Win95/98系(非対応だが一応)
			if ( Win32Platform == VER_PLATFORM_WIN32_WINDOWS ){
				OneLine =
					"Fn_" + IntToStr((int)Index) + ":" +                 //インデックス
					FileNameString + "\\\t" +                            //ディレクトリ名
					"*\t16\t0\t0\t0\t0";                                 //残りは0
			}
			else{
				// _WIN32_FIND_DATAW 構造体
				//fd = sr.FindData;
				OneLine =
					"Fn_" + IntToStr((int)Index) + ":" +                 //インデックス
					FileNameString + "\\\t" +                            //ディレクトリの相対パス
					"*\t" +                                              //ファイルサイズ(=0)
					IntToStr(sr.Attr) + "\t" +                           //属性
					TimeStampToString(sr.FindData.ftLastWriteTime)+"\t"+ //更新日時
					TimeStampToString(sr.FindData.ftCreationTime);       //作成日時

					//出力する暗号化ファイルのタイムスタンプを元ファイルに合わせるため保持
					if ( fKeepTimeStamp == true && first_fd.cFileName[0] == NULL ) {
						first_fd = sr.FindData;
					}

			}

			FileList->Add("");      //ディレクトリは空行
			DataList->Add(OneLine);
			Index++;

			if (fParent == false) {
				//再帰呼び出し
				TotalSize += GetFileInfoList(Index, FilePath, "", BasePath, FileList, DataList);
			}

		}
		//-----------------------------------
		//ファイル
		else{
			OneLine =
				"Fn_" + IntToStr((int)Index) + ":" +                   //インデックス
				FileNameString + "\t" +                                //ファイルの相対パス
				IntToStr(sr.Size) + "\t" +                             //ファイルサイズ
				IntToStr(sr.Attr) + "\t" +                             //属性
				TimeStampToString(sr.FindData.ftLastWriteTime)+"\t"+   //更新日時
				TimeStampToString(sr.FindData.ftCreationTime);         //作成日時

			//出力する暗号化ファイルのタイムスタンプを元ファイルに合わせるため保持
			if ( fKeepTimeStamp == true && first_fd.cFileName[0] == NULL ) {
				first_fd = sr.FindData;
			}

			if (sr.Size > 0) {
				FileList->Add(FilePath);
			}
			else{
				FileList->Add("");      //空ファイルは加えない
			}

			DataList->Add(OneLine);
			Index++;

			//ファイル総計
			TotalSize += sr.Size;

		}
		//-----------------------------------

	}//end if;

	ret = FindNext(sr);

}//while;

FindClose(sr);

return(TotalSize);


}//end GetFileInfoList;
开发者ID:Seidou,项目名称:AttacheCase,代码行数:101,代码来源:TAttacheCaseFileEncrypt.cpp


示例15: loadmodels

void loadmodels()
{
	WIN32_FIND_DATA FindFileData = {0};
    char sTmp[256] = {0};

	ModelNumWater=GetPrivateProfileInt("Set","ModelNumWater",10,".\\Model.ini");
	pModelIDWater=new int[ModelNumWater];
	sprintf(sTmp,"Data/Model/Waters/*.dds");
	HANDLE hFind = ::FindFirstFile(sTmp, &FindFileData);
	if(INVALID_HANDLE_VALUE != hFind)
	{		
		while(ModelNumLoadedWater<ModelNumWater)
		{
			if (FindFileData.cFileName[0] != '.')
			{
				pModelIDWater[ModelNumLoadedWater]=0;
				char sTmp2[256] = {0};
				char loadModelpathName[256] = {0};
				int tmpi=0;
				for(unsigned int i=0;i<strlen(FindFileData.cFileName);i++)
				{
					if(i<256)
					{
						if(FindFileData.cFileName[i]=='.')
							sTmp2[i]=0;
						else
							sTmp2[i]=FindFileData.cFileName[i];
					}
				}
				sprintf(loadModelpathName,"Data/Model/Waters/%s",sTmp2);
				pModelIDWater[ModelNumLoadedWater]=m_VBMD->Init(loadModelpathName);
				ModelNumLoadedWater=ModelNumLoadedWater+1;
			}
			if(!FindNextFile(hFind, &FindFileData))
				break;
		}
		FindClose(hFind);
	}



	ModelNum=GetPrivateProfileInt("Set","ModelNum",290,".\\Model.ini");
	pModelID=new int[ModelNum];

	sprintf(sTmp,"Data/Model/*.dds");
	hFind = ::FindFirstFile(sTmp, &FindFileData);
	if(INVALID_HANDLE_VALUE == hFind)
		MessageBox( NULL, "FindNoFile", "ERROR", MB_OK|MB_ICONEXCLAMATION );
	else
	{
		while(ModelNumLoaded<ModelNum)
		{
			if (FindFileData.cFileName[0] != '.')
			{
				pModelID[ModelNumLoaded]=0;
				char sTmp2[256] = {0};
				char loadModelpathName[256] = {0};
				int tmpi=0;
				for(unsigned int i=0;i<strlen(FindFileData.cFileName);i++)
				{
					if(i<256)
					{
						if(FindFileData.cFileName[i]=='.')
							sTmp2[i]=0;
						else
							sTmp2[i]=FindFileData.cFileName[i];
					}
				}
				sprintf(loadModelpathName,"Data/Model/%s",sTmp2);
				pModelID[ModelNumLoaded]=m_VBMD->Init(loadModelpathName);
				ModelNumLoaded=ModelNumLoaded+1;
			}
			if(!FindNextFile(hFind, &FindFileData))
				break;
		}
		FindClose(hFind);
	
	}

	sprintf(sTmp,"Data/Model/Alpha/*.dds");
	hFind = ::FindFirstFile(sTmp, &FindFileData);
	if(INVALID_HANDLE_VALUE != hFind)
	{		
		while(ModelNumLoaded<ModelNum)
		{
			if (FindFileData.cFileName[0] != '.')
			{
				pModelID[ModelNumLoaded]=0;
				char sTmp2[256] = {0};
				char loadModelpathName[256] = {0};
				int tmpi=0;
				for(unsigned int i=0;i<strlen(FindFileData.cFileName);i++)
				{
					if(i<256)
					{
						if(FindFileData.cFileName[i]=='.')
							sTmp2[i]=0;
						else
							sTmp2[i]=FindFileData.cFileName[i];
					}
//.........这里部分代码省略.........
开发者ID:SHIYUENING,项目名称:topace,代码行数:101,代码来源:Lesson46.cpp


示例16: listFiles

void listFiles(const std::string & dir, const bool recurse, std::vector<std::string> & files, bool & abort)
{
	std::vector<std::string> childDirs;
	std::string child_name;

#ifdef WINDOWS
	WIN32_FIND_DATA fileData;
	std::string child_search = (dir + PATH_SEP) + "*";
	HANDLE fileHandle = FindFirstFile(child_search.c_str(), &fileData);

	// empty directory
	if (fileHandle == INVALID_HANDLE_VALUE)
	{
		return;
	}

	// process the next child in the driectory
	while (FindNextFile(fileHandle, &fileData) != 0) 
	{
		child_name = fileData.cFileName;
#else
	DIR * directory = opendir(dir.c_str());
	struct dirent entry;
	struct dirent * next_entry;
	if (NULL == directory)
	{
		return;
	}

	while (0 == readdir_r(directory, &entry, &next_entry) && next_entry != NULL)
	{
		child_name = entry.d_name;
#endif

		abort = (abort_monitor == child_name);

		// if the child represents the directory itself, or its parent, skip
		if (child_name == "." || child_name == "..")
			continue;

		// build the full path
		std::string child = dir + PATH_SEP + child_name;

		// deal appropriately with the file depending on whether it is a directory or file
/*#ifdef WINDOWS
		if ((fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
#else
#error Not implemented
#endif
*/
		if (dirExists(child))
		{
			// if not doing a recursive search, no point in even adding to the list
			if (recurse)
				continue;

			childDirs.push_back(child);
		}
		else
		{
			files.push_back(child);
		}
	}

#ifdef WINDOWS
	FindClose(fileHandle);
#else
	closedir(directory);
#endif

	if (recurse)
	{
		for(std::vector<std::string>::const_iterator cDir = childDirs.begin(); cDir != childDirs.end(); ++cDir)
			listFiles(*cDir, recurse, files, abort);
	}
}

// not passed-by-ref on purpose - need a copy here
bool hasRarSuffix(std::string s)
{
	// file must be at least a.rar long
	if (s.length() < 5)
		return false;
	
	toLower(s);

	// index s.length() - 1 points to r
	// index s.length() - 4 points to .
	return (s.substr(s.length() - 4) == ".rar");
}

bool isDigit(char c)
{
	return c >= '0' && c <= '9';
}

bool hasR01Suffix(std::string s)
{
	// .rXX
	s = s.substr(s.length() - 4);
//.........这里部分代码省略.........
开发者ID:jackleaks,项目名称:stream-unrar,代码行数:101,代码来源:stream_unrar.cpp


示例17: DeleteDirectoryW

BOOL DeleteDirectoryW(const WCHAR* sPath) {



    HANDLE hFind;  // file handle

    WIN32_FIND_DATAW FindFileData;
    
    WCHAR DirPath[MAX_PATH+0x200];
    WCHAR FileName[MAX_PATH+0x200];
    
    StringCchCopyW(DirPath,MAX_PATH+0x200,sPath);
    StringCchCatW(DirPath,MAX_PATH+0x200,L"\\*");    // searching all files
    
    StringCchCopyW(FileName,MAX_PATH+0x200,sPath);
    StringCchCatW(FileName,MAX_PATH+0x200,L"\\");
    
    hFind = FindFirstFileExW(DirPath,FindExInfoBasic,&FindFileData,FindExSearchNameMatch,NULL,0); // find the first file
    if(hFind == INVALID_HANDLE_VALUE) return FALSE;
    StringCchCopyW(DirPath,MAX_PATH+0x200,FileName);
    
    bool bSearch = true;
    while(bSearch) { // until we finds an entry
        if(FindNextFileW(hFind,&FindFileData)) {
            if(IsDotsW(FindFileData.cFileName)) continue;
			StringCchCatW(FileName,MAX_PATH+0x200,FindFileData.cFileName);
            //strcat(FileName,FindFileData.cFileName);
            if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
                
                // we have found a directory, recurse
                if(!DeleteDirectoryW(FileName)) { 
                    FindClose(hFind); 
                    return FALSE; // directory couldn't be deleted
                }
                RemoveDirectoryW(FileName); // remove the empty directory
                //strcpy(FileName,DirPath);
				StringCchCopyW(FileName,MAX_PATH+0x200,DirPath);
            }
            else {

                if(!DeleteFileW(FileName)) {  // delete the file
                    FindClose(hFind); 
                    return FALSE; 
                }                 
                //strcpy(FileName,DirPath);
				StringCchCopyW(FileName,MAX_PATH+0x200,DirPath);
            }
        }
        else {
            if(GetLastError() == ERROR_NO_MORE_FILES) // no more files there
                bSearch = false;
            else {
                // some error occured, close the handle and return FALSE
                FindClose(hFind); 
                return FALSE;
            }
            
        }
        
    }
    FindClose(hFind);  // closing file handle
    
    return RemoveDirectoryW(sPath); // remove the empty directory
    
}
开发者ID:Rajat-dhyani,项目名称:UnitexGramLab,代码行数:65,代码来源:UnitexLibDirWin.cpp


示例18: Sys_EnumerateFiles2

static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart, int (QDECL *func)(const char *fname, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
{
	qboolean go;
	if (!WinNT)
	{
		HANDLE r;
		WIN32_FIND_DATAA fd;
		int nest = neststart;	//neststart refers to just after a /
		qbool 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FindCommand函数代码示例发布时间:2022-05-30
下一篇:
C++ FindClient函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap