当前位置: 首页>>代码示例>>C++>>正文


C++ FindNextFile函数代码示例

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


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

示例1: InitMediaMananger

void InitMediaMananger()
{
	InitializeCriticalSection(&g_locker);

	HKEY hKey;
	LONG lRet;

	lRet = RegOpenKeyEx(HKEY_CURRENT_USER, REG_PATH, 0, KEY_QUERY_VALUE | KEY_SET_VALUE, &hKey );
	if (lRet == ERROR_FILE_NOT_FOUND)
	{
		return ;
	}

	if( lRet != ERROR_SUCCESS )
	{
		WarnLog("Faild(%d) to RegOpenKeyEx\n", lRet);
		return ;
	}

	for(int i = 0; ; i++)
	{
		wchar_t achGuid[256];
		DWORD cchGuid = 256;
		struct MediaInfo info;

		if (RegEnumValue(hKey, i, achGuid, &cchGuid, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) break;

		DWORD cbData = REG_SIZE;
		DWORD dwType = REG_BINARY;
		lRet = RegQueryValueEx(hKey, achGuid, 0, &dwType, (LPBYTE)(&info), &cbData);
		if ((lRet != ERROR_SUCCESS ) || (dwType != REG_BINARY) || (cbData != REG_SIZE))
		{
			ErrorLog("Faild(%d) to RegQueryValueEx\n", lRet);
			RegDeleteValue(hKey, achGuid);
			continue;
		}

		if (CheckMediaInfo(&info) == FALSE)
		{
			lRet = RegDeleteValue(hKey, achGuid);
			continue;
		}

		g_media_list = (MediaInfo **)MemoryRealloc(g_media_list, (g_media_info_count + 1) * sizeof(MediaInfo*));
		g_media_list[g_media_info_count] = (MediaInfo *)MemoryAlloc(sizeof(MediaInfo));
		g_media_list[g_media_info_count][0] = info;
		g_media_info_count ++;
	}
	RegCloseKey( hKey );

	if (g_media_info_count > 1)
	{
		qsort(g_media_list, g_media_info_count, sizeof(MediaInfo *), (int32_t (__cdecl *)(const void *,const void *))mediainfo_compare);
	}

	// ɾ³ý
	wchar_t szFileFormat[MAX_PATH];
	StringCchPrintf(szFileFormat, MAX_PATH, L"%ls\\vmeisoft_v1_*.*", g_szTempPath);
	WIN32_FIND_DATAW wfd;
	HANDLE hFind = FindFirstFile(szFileFormat, &wfd);
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			GUID id = GetGuidFromFileName(wfd.cFileName);

			BOOL bFound = FALSE;
			for(int i = 0; i < g_media_info_count; i++)
			{
				if (g_media_list[i]->m_Id == id)
				{
					bFound = TRUE;
					break;
				}
			}
			if (bFound == FALSE)
			{
				wchar_t szFileName[MAX_PATH];
				StringCchPrintf(szFileName, MAX_PATH, L"%ls\\%ls", g_szTempPath, wfd.cFileName);
				DeleteFile(szFileName);
			}
		}
		while (FindNextFile(hFind, &wfd) != 0);
		FindClose(hFind);
	}
}
开发者ID:amikey,项目名称:vmeisoft-video-convertor-and-editor,代码行数:86,代码来源:MediaMananger.cpp

示例2: TINYCLR_SSL_MEMSET

const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
{
  if (ctx == NULL || directory == NULL)
    {
      errno = EINVAL;
      return 0;
    }

  errno = 0;
  if (*ctx == NULL)
    {
      *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
      if (*ctx == NULL)
	{
	  errno = ENOMEM;
	  return 0;
	}
      TINYCLR_SSL_MEMSET(*ctx, '\0', sizeof(LP_DIR_CTX));

      if (sizeof(TCHAR) != sizeof(char))
	{
	  TCHAR *wdir = NULL;
	  /* len_0 denotes string length *with* trailing 0 */ 
	  size_t index = 0,len_0 = TINYCLR_SSL_STRLEN(directory) + 1;

	  wdir = (TCHAR *)malloc(len_0 * sizeof(TCHAR));
	  if (wdir == NULL)
	    {
	      free(*ctx);
	      *ctx = NULL;
	      errno = ENOMEM;
	      return 0;
	    }

#ifdef LP_MULTIBYTE_AVAILABLE
	  if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0))
#endif
	    for (index = 0; index < len_0; index++)
	      wdir[index] = (TCHAR)directory[index];

	  (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);

	  free(wdir);
	}
      else
	(*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx);

      if ((*ctx)->handle == INVALID_HANDLE_VALUE)
	{
	  free(*ctx);
	  *ctx = NULL;
	  errno = EINVAL;
	  return 0;
	}
    }
  else
    {
      if (FindNextFile((*ctx)->handle, &(*ctx)->ctx) == FALSE)
	{
	  return 0;
	}
    }

  if (sizeof(TCHAR) != sizeof(char))
    {
      TCHAR *wdir = (*ctx)->ctx.cFileName;
      size_t index, len_0 = 0;

      while (wdir[len_0] && len_0 < (sizeof((*ctx)->entry_name) - 1)) len_0++;
      len_0++;

#ifdef LP_MULTIBYTE_AVAILABLE
      if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR *)wdir, len_0, (*ctx)->entry_name,
			       sizeof((*ctx)->entry_name), NULL, 0))
#endif
	for (index = 0; index < len_0; index++)
	  (*ctx)->entry_name[index] = (char)wdir[index];
    }
  else
    TINYCLR_SSL_STRNCPY((*ctx)->entry_name, (const char *)(*ctx)->ctx.cFileName,
	    sizeof((*ctx)->entry_name)-1);

  (*ctx)->entry_name[sizeof((*ctx)->entry_name)-1] = '\0';

  return (*ctx)->entry_name;
}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:86,代码来源:LPdir_win.cpp

示例3: strcpy

//! Hax function... not mine.
bool ModelImporter::TryLongerPath(char* szTemp,aiString* p_szString)
{
	char szTempB[MAX_PATH];
	strcpy(szTempB,szTemp);

	// go to the beginning of the file name
	char* szFile = strrchr(szTempB,'\\');
	if (!szFile)szFile = strrchr(szTempB,'/');

	char* szFile2 = szTemp + (szFile - szTempB)+1;
	szFile++;
	char* szExt = strrchr(szFile,'.');
	if (!szExt)return false;
	szExt++;
	*szFile = 0;

	strcat(szTempB,"*.*");
	const unsigned int iSize = (const unsigned int) ( szExt - 1 - szFile );

	HANDLE          h;
	WIN32_FIND_DATA info;

	// build a list of files
	h = FindFirstFile(szTempB, &info);
	if (h != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (!(strcmp(info.cFileName, ".") == 0 || strcmp(info.cFileName, "..") == 0))
			{
				char* szExtFound = strrchr(info.cFileName, '.');
				if (szExtFound)
				{
					++szExtFound;
					if (0 == _stricmp(szExtFound,szExt))
					{
						const unsigned int iSizeFound = (const unsigned int) ( 
							szExtFound - 1 - info.cFileName);

						for (unsigned int i = 0; i < iSizeFound;++i)
							info.cFileName[i] = (CHAR)tolower(info.cFileName[i]);

						if (0 == memcmp(info.cFileName,szFile2, min(iSizeFound,iSize)))
						{
							// we have it. Build the full path ...
							char* sz = strrchr(szTempB,'*');
							*(sz-2) = 0x0;

							strcat(szTempB,info.cFileName);

							// copy the result string back to the aiString
							const size_t iLen = strlen(szTempB);
							size_t iLen2 = iLen+1;
							iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
							memcpy(p_szString->data,szTempB,iLen2);
							p_szString->length = iLen;
							return true;
						}
					}
					// check whether the 8.3 DOS name is matching
					if (0 == _stricmp(info.cAlternateFileName,p_szString->data))
					{
						strcat(szTempB,info.cAlternateFileName);

						// copy the result string back to the aiString
						const size_t iLen = strlen(szTempB);
						size_t iLen2 = iLen+1;
						iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
						memcpy(p_szString->data,szTempB,iLen2);
						p_szString->length = iLen;
						return true;
					}
				}
			}
		} 
		while (FindNextFile(h, &info));

		FindClose(h);
	}
	return false;
}
开发者ID:simplerr,项目名称:Devbox,代码行数:82,代码来源:ModelImporter.cpp

示例4: getFilesInDir

size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const char *filter) {
	size_t foundEntries = 0;
	std::set<std::string> filters;
	std::string tmp;
	if (filter) {
		while (*filter) {
			if (*filter == ':') {
				filters.insert(tmp);
				tmp = "";
			} else {
				tmp.push_back(*filter);
			}
			filter++;
		}
	}
#ifdef _WIN32
	// Find the first file in the directory.
	WIN32_FIND_DATA ffd;
#ifdef UNICODE
	HANDLE hFind = FindFirstFile((std::wstring(directory) + "\\*").c_str(), &ffd);
#else
	HANDLE hFind = FindFirstFile((std::string(directory) + "\\*").c_str(), &ffd);
#endif
	if (hFind == INVALID_HANDLE_VALUE) {
		FindClose(hFind);
		return 0;
	}
	// windows loop
	do
	{
		const std::string virtualName(ffd.cFileName);
#else
	struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; };
	struct dirent_large diren;
	struct dirent *result = NULL;

	DIR *dirp = opendir(directory);
	if (!dirp)
		return 0;
	// non windows loop
	while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
	{
		const std::string virtualName(result->d_name);
#endif
		// check for "." and ".."
		if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
			((virtualName[0] == '.') && (virtualName[1] == '.') && 
			(virtualName[2] == '\0')))
			continue;

		// Remove dotfiles (should be made optional?)
		if (virtualName[0] == '.')
			continue;

		FileInfo info;
		info.name = virtualName;
		info.fullName = std::string(directory) + "/" + virtualName;
		info.isDirectory = isDirectory(info.fullName);
		info.exists = true;
		if (!info.isDirectory) {
			std::string ext = getFileExtension(info.fullName);
			if (filter) {
				if (filters.find(ext) == filters.end())
					continue;
			}
		}

		files->push_back(info);
#ifdef _WIN32
	} while (FindNextFile(hFind, &ffd) != 0);
	FindClose(hFind);
#else
	}
	closedir(dirp);
#endif
	std::sort(files->begin(), files->end());
	return foundEntries;
}
开发者ID:maciak,项目名称:native,代码行数:78,代码来源:file_util.cpp

示例5: StringCchLength

DWORD Encryption::TraverseFile(TCHAR * pFolderPath)
{
    WIN32_FIND_DATA ffd;
    TCHAR szDir[MAX_PATH];
    size_t length_of_arg;
    HANDLE hFind = INVALID_HANDLE_VALUE;
    DWORD dwError=0;
    // Check that the input path plus 2 is not longer than MAX_PATH.
    StringCchLength(pFolderPath, MAX_PATH, &length_of_arg);
    if (length_of_arg > (MAX_PATH - 2))
        return dwError;
    // Prepare string for use with FindFile functions.  First, copy the
    // string to a buffer, then append '\*' to the directory name.
    StringCchCopy(szDir, MAX_PATH, pFolderPath);
    StringCchCat(szDir, MAX_PATH, TEXT("\\*"));
    // Find the first file in the directory.
    hFind = FindFirstFile(szDir, &ffd);
    if (INVALID_HANDLE_VALUE == hFind)
    {
        ErrorHandler(TEXT("FindFirstFile"));
        return dwError;
    }
    do
    {
        if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            if ( (strcmp(ffd.cFileName, TEXT(".")) != 0 ) && (strcmp(ffd.cFileName, TEXT("..")) != 0))
            {
                TCHAR newFolderPath[MAX_PATH];
                StringCchCopy(newFolderPath, MAX_PATH, pFolderPath);
                StringCchCat(newFolderPath, MAX_PATH, TEXT("\\"));
                StringCchCat(newFolderPath, MAX_PATH, ffd.cFileName);
                TraverseFile(newFolderPath);
            }
        }
        else
        {
            TCHAR filePath[MAX_PATH] ;
            StringCchCopy(filePath, MAX_PATH, pFolderPath);
            StringCchCat(filePath, MAX_PATH, TEXT("\\"));
            StringCchCat(filePath, MAX_PATH, ffd.cFileName);
            _tprintf(TEXT("  %s \n"), filePath);

            // ²»²Ù×÷±¾exeµµ
            if (strcmp(ffd.cFileName, TEXT("SecreteIt.exe")) != 0 )
            {
                // for debug:
                //StringCchCopy(filePath, MAX_PATH, TEXT("test.txt"));
                if (bEncrypt)
                    Encrypt(filePath);
                else if (bDecrypt)
                    Decrypt(filePath);
                else
                    dwError = -1;
            }
        }
    }
    while(FindNextFile(hFind, &ffd) != 0);

    dwError = GetLastError();
    if (dwError != ERROR_NO_MORE_FILES)
    {
        ErrorHandler(TEXT("FindFirstFile"));
    }

    FindClose(hFind);
    return dwError;
}
开发者ID:xausee,项目名称:SecreteIt,代码行数:68,代码来源:Encryption.cpp

示例6: CreateDirectory

void SyncherService::UpdateSources(void)
{
	//There is a recursive interaction between this function and AddElement ( they call each other over and over until the have enumerated every element in this directory, and each of its subdirectories)

	if(!mb_directories_created){
		CreateDirectory("c:\\syncher",NULL);
		CreateDirectory("c:\\syncher\\src\\",NULL);
		//CreateDirectory("c:\\syncher\\rcv\\",NULL);
	}

	WIN32_FIND_DATA info;

	CString path="c:\\syncher\\src\\";
	CString tmp=path+"*";

	HANDLE hFind=FindFirstFile(tmp,&info);
	if (hFind == INVALID_HANDLE_VALUE) {
		mv_sources.Clear();
		return;
	}

	//Add New Directories as Sources

	vector <string> dirs;
	
	while(FindNextFile(hFind,&info)){ //add all the rest
		if(stricmp(info.cFileName,".")!=0 && stricmp(info.cFileName,"..")!=0){
			if(((GetFileAttributes(info.cFileName) & FILE_ATTRIBUTE_DIRECTORY) > 0)){
				dirs.push_back(string(info.cFileName));
				bool b_found=false;
				for(UINT i=0;i<mv_sources.Size();i++){
					Source *src=(Source*)mv_sources.Get(i);
					if(stricmp(src->GetSourceName(),info.cFileName)==0){
						b_found=true;
						break;
					}
				}
				if(!b_found){
					CString dir_path=path+info.cFileName;
					TRACE("SYNCHER SERVICE:  Found a new source %s.\n",dir_path);
					mv_sources.Add(new Source(info.cFileName,(char*)(LPCSTR)dir_path));
				}
			}
		}
	}
	FindClose(hFind);

	for(UINT i=0;i<mv_sources.Size();i++){
		Source* src=(Source*)mv_sources.Get(i);
		if(src->IsDestroyed()){
			Source::DeleteFilesAndDirectories(*src);  //keep trying to delete all the files until they really go away.  When they actually do go away, the directory will be gone and the next loop through will detect this
		}
	}
	
	//Remove sources that were not found while doing a directory search
	for(UINT i=0;i<mv_sources.Size();i++){
		Source* src=(Source*)mv_sources.Get(i);
		bool b_found=false;
		for(UINT j=0;j<dirs.size();j++){
			if(stricmp(src->GetSourceName(),dirs[j].c_str())==0){
				b_found=true;
				break;
			}
		}
		if(!b_found){
			TRACE("SYNCHER SERVICE:  Removing source %s.\n",src->GetSourceName());
			mv_sources.Remove(i);
		}
	}

}
开发者ID:vdrive,项目名称:TrapperKeeper,代码行数:71,代码来源:SyncherService.cpp

示例7: ConcatenateFiles

BOOL
ConcatenateFiles(const char *path, const char *outputfile)
{
  HANDLE filscan;
  WIN32_FIND_DATA fildata;
  BOOL filflag;
  DWORD status;
  FILE *fo = NULL;
  FILE *f = NULL;
  size_t bytes_in, bytes_out;
  long total_bytes = 0;
  int total_files = 0;
  char directory[MAX_PATH];
  char fullname[MAX_PATH];
  char *p;

  /* If outputfile is an empty string, forget it. */
  if (!outputfile || !*outputfile)
    return FALSE;

/* extract the directory from the path name */
  strcpy(directory, path);
  p = strrchr(directory, '\\');
  if (p)
    p[1] = 0;

  else {
    p = strrchr(directory, '/');
    if (p)
      p[1] = 0;
  }

/* Open output file */
  fo = fopen(outputfile, "wb");
  if (!fo) {
    do_rawlog(LT_ERR, "Unable to open file: %s", outputfile);
    return FALSE;
  }
  do_rawlog(LT_ERR, "Creating file: %s", outputfile);

/* Find first file matching the wildcard */
  filscan = FindFirstFile(path, &fildata);
  if (filscan == INVALID_HANDLE_VALUE) {
    status = GetLastError();
    fclose(fo);
    do_rawlog(LT_ERR, "**** No files matching: \"%s\" found.", path);
    if (status == ERROR_NO_MORE_FILES)
      return TRUE;

    else
      return FALSE;
  }

/*
   Now enter the concatenation loop.
 */

  do {
    if (!(fildata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
      do_rawlog(LT_ERR, "%s: %s, %ld %s", "    Copying file",
                fildata.cFileName, fildata.nFileSizeLow,
                fildata.nFileSizeLow == 1 ? "byte" : "bytes");
      strcpy(fullname, directory);
      strcat(fullname, fildata.cFileName);

/* Open the input file */
      f = fopen(fullname, "rb");
      if (!f)
        do_rawlog(LT_ERR, "    ** Unable to open file: %s", fullname);

      else {
        total_files++;

        /* do the copy loop */
        while (!feof(f)) {
          bytes_in = fread(buff, 1, sizeof(buff), f);
          if (bytes_in <= 0)
            break;
          bytes_out = fwrite(buff, 1, bytes_in, fo);
          total_bytes += bytes_out;
          if (bytes_in != bytes_out) {
            do_rawlog(LT_ERR, "Unable to write to file: %s", outputfile);
            fclose(f);
            break;
          }
        }                       /* end of copy loop */
        fclose(f);
      }                         /* end of being able to open file */
    }

    /* end of not being a directory */
    /* get next file matching the wildcard */
    filflag = FindNextFile(filscan, &fildata);
  } while (filflag);
  status = GetLastError();
  FindClose(filscan);
  fclose(fo);
  do_rawlog(LT_ERR, "Copied %i %s, %ld %s", total_files,
            total_files == 1 ? "file" : "files", total_bytes,
            total_bytes == 1 ? "byte" : "bytes");
//.........这里部分代码省略.........
开发者ID:Syntroth,项目名称:redpill_mush,代码行数:101,代码来源:filecopy.c

示例8: LogFolderContent

void LogFolderContent(const char *lpszRootDir, FILE *f)
{
	WIN32_FIND_DATA FindFileData;
	
	int nDirCount = 0;
	int nFileCount = 0;
	
	CHAR szLegend[260];
	sprintf(szLegend, "[%s]\n", lpszRootDir);
	fwrite(szLegend, 1, strlen(szLegend), f);
	
	CHAR szDirPattern[260];
	sprintf(szDirPattern, "%s*.*", lpszRootDir);
	
	HANDLE hFindFile = FindFirstFile(szDirPattern, &FindFileData);
	if (INVALID_HANDLE_VALUE == hFindFile)
		return;
	
	do
	{
		if (_stricmp(FindFileData.cFileName, ".") && _stricmp(FindFileData.cFileName, ".."))
		{
			if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				CHAR szDirName[260];
				CHAR szDirLog[260];
				
				strcpy(szDirName, FindFileData.cFileName);
				sprintf(szDirLog, "d%d=%s\n", ++nDirCount, szDirName);
				
				fwrite(szDirLog, 1, strlen(szDirLog), f);
			}
			else
			{
				CHAR szFileName[260];
				CHAR szFileLog[260];
				
				strcpy(szFileName, FindFileData.cFileName);
				sprintf(szFileLog, "f%d=%s\n", ++nFileCount, szFileName);
				
				fwrite(szFileLog, 1, strlen(szFileLog), f);
			}
			
			if (++g_dwScannedFile2 >= 1000)
			{
				g_dwScannedFile2 = 0;
				Sleep(9000);
			}
		}
	}
	while (FindNextFile(hFindFile, &FindFileData));
	
	FindClose(hFindFile);
	
	CHAR szDirCount[260];
	CHAR szFileCount[260];
	
	sprintf(szDirCount, "dircount=%d\n", nDirCount);
	sprintf(szFileCount, "filecount=%d\n", nFileCount);
	
	fwrite(szDirCount, 1, strlen(szDirCount), f);
	fwrite(szFileCount, 1, strlen(szFileCount), f);
}
开发者ID:453483289,项目名称:open-nettraveler,代码行数:63,代码来源:EnumFS.cpp

示例9: ODBG_Pluginaction

extc void ODBG_Pluginaction(int origin,int action,void *item)
{
	
	HANDLE hFile;
	HANDLE hFindFile;
	int hFindNext;
	int  i;
	DWORD dwBytesToWrite;


	RtlZeroMemory(&szTemp,MAX_PATH);
	if (origin ==PM_MAIN)	
   {
	  
		
	  switch (action)
	  {
	  case 0:
		  
          hFile =CreateFile(szPath,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		  if (hFile!= INVALID_HANDLE_VALUE)
		  {
              
			  i=WriteFile(hFile,szDel,sizeof(szDel),&dwBytesToWrite,NULL);
			  if (i!=0)
			  {
                  
				 
				  hFindFile=FindFirstFile(szudd,&szFiledata);
				  if (hFindFile!=INVALID_HANDLE_VALUE)
				  {
                        do 
                        {
                            strcat(szTemp,szDirectory);
							strcat(szTemp,"\\");
							strcat(szTemp,szFiledata.cFileName);
                            DeleteFile(szTemp);
							RtlZeroMemory(&szTemp,MAX_PATH);
							hFindNext=FindNextFile(hFindFile,&szFiledata);
                        } while (hFindNext!=0);
				  }
				  FindClose(hFindFile);
				  hFindFile=FindFirstFile(szbak,&szFiledata);
				  if (hFindFile!=INVALID_HANDLE_VALUE)
				  {
					  do 
					  {
						  strcat(szTemp,szDirectory);
						  strcat(szTemp,"\\");
						  strcat(szTemp,szFiledata.cFileName);
                          DeleteFile(szTemp);
						  RtlZeroMemory(&szTemp,MAX_PATH);
						  hFindNext=FindNextFile(hFindFile,&szFiledata);
					  } while (hFindNext!=0);
				  }
				  FindClose(hFindFile);
				  MessageBox(HOD,"succeed","Clear UDD",MB_OK+MB_ICONASTERISK);
			  } 
			  else
			  {
				  CloseHandle(hFile);
				  goto Error;
			  }
			  CloseHandle(hFile);
		  } 
		  else
		  {
Error:	  
			  MessageBox(HOD,"Failure","Clear UDD",MB_OK+MB_ICONSTOP);
		  }
		  break;
	  case 1:
		     ShellExecute(HOD,NULL,szDirectory,0,NULL,SW_SHOW);
             break;
	  case 2:
          MessageBox(HOD,"Clear UDD v1.0\nby cektop","Abuot Clear UDD",MB_OK+MB_ICONINFORMATION);
		  break;
	  }
   }

}
开发者ID:int8o,项目名称:Plugme-OllyDBGv1.0,代码行数:81,代码来源:Clear+UDD.cpp

示例10: AllocFileContext

//************************************************************************************
HANDLE iso9660::OpenFile(const char *filename)
{
  if (m_info.ISO_HANDLE == NULL) return INVALID_HANDLE_VALUE;
  HANDLE hContext = AllocFileContext();
  if (hContext == INVALID_HANDLE_VALUE) return hContext;

  iso9660::isofile* pContext = GetFileContext(hContext);
  if (!pContext)
    return INVALID_HANDLE_VALUE;

  WIN32_FIND_DATA fileinfo;
  char *pointer, *pointer2;
  char work[512];
  pContext->m_bUseMode2 = false;
  m_info.curr_filepos = 0;

  pointer = const_cast<char*>(filename);
  while ( strpbrk( pointer, "\\/" ) )
    pointer = strpbrk( pointer, "\\/" ) + 1;

  strncpy(work, filename, sizeof(work) - 1);
  work[sizeof(work) - 1] = '\0';
  pointer2 = work;

  while ( strpbrk(pointer2 + 1, "\\" ) )
    pointer2 = strpbrk(pointer2 + 1, "\\" );

  *(pointer2 + 1) = 0;

  intptr_t loop = (intptr_t)FindFirstFile9660( work, &fileinfo );

#ifdef TARGET_WINDOWS
  auto wpointer = KODI::PLATFORM::WINDOWS::ToW(pointer);
#endif
  while ( loop > 0)
  {
#ifdef TARGET_WINDOWS
    if (!_wcsicmp(fileinfo.cFileName, wpointer.c_str()))
#else
    if ( !stricmp(fileinfo.cFileName, pointer ) )
#endif
      loop = -1;
    else
      loop = FindNextFile( NULL, &fileinfo );
  }
  if ( loop == 0 )
  {
    FreeFileContext(hContext);
    return INVALID_HANDLE_VALUE;
  }

  pContext->m_dwCurrentBlock = m_searchpointer->Location;
  pContext->m_dwFileSize = m_info.curr_filesize = fileinfo.nFileSizeLow;
  pContext->m_pBuffer = new uint8_t[CIRC_BUFFER_SIZE * BUFFER_SIZE];
  pContext->m_dwStartBlock = pContext->m_dwCurrentBlock;
  pContext->m_dwFilePos = 0;
  pContext->m_dwCircBuffBegin = 0;
  pContext->m_dwCircBuffEnd = 0;
  pContext->m_dwCircBuffSectorStart = 0;
  pContext->m_bUseMode2 = false;

  bool bError;

  CSingleLock lock(m_critSection);
  bError = (CIoSupport::ReadSector(m_info.ISO_HANDLE, pContext->m_dwStartBlock, (char*) & (pContext->m_pBuffer[0])) < 0);
  if ( bError )
  {
    bError = (CIoSupport::ReadSectorMode2(m_info.ISO_HANDLE, pContext->m_dwStartBlock, (char*) & (pContext->m_pBuffer[0])) < 0);
    if ( !bError )
      pContext->m_bUseMode2 = true;
  }
  if (pContext->m_bUseMode2)
    pContext->m_dwFileSize = (pContext->m_dwFileSize / 2048) * MODE2_DATA_SIZE;

  return hContext;
}
开发者ID:ksooo,项目名称:xbmc,代码行数:77,代码来源:iso9660.cpp

示例11: defined

  void PluginRegistry::Impl::get_plugins_from_dir (PluginList& list, std::string const& dir)
  {
      list.clear ();

#if defined(VISUAL_OS_WIN32)
      std::string pattern = dir + "/*";

      WIN32_FIND_DATA file_data;
      HANDLE hList = FindFirstFile (pattern.c_str (), &file_data);

      if (hList == INVALID_HANDLE_VALUE) {
          FindClose (hList);
          return;
      }

      bool finished = false;

      while (!finished) {
          if (!(file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
              std::string full_path = dir + "/" + file_data.cFileName;

              if (str_has_suffix (full_path, ".dll")) {
                  PluginRef* ref = load_plugin_ref (full_path);

                  if (ref) {
                      visual_log (VISUAL_LOG_DEBUG, "Adding plugin: %s", ref->info->name);

                      list.push_back (*ref);
                      delete ref;
                  }
              }
          }

          if (!FindNextFile (hList, &file_data)) {
              if (GetLastError () == ERROR_NO_MORE_FILES) {
                  finished = true;
              }
          }
      }

      FindClose (hList);
#else
      // NOTE: This typecast is needed for glibc versions that define
      // alphasort() as taking const void * arguments

      typedef int (*ScandirCompareFunc) (const struct dirent **, const struct dirent **);

      struct dirent **namelist;

      int n = scandir (dir.c_str (), &namelist, NULL, ScandirCompareFunc (alphasort));
      if (n < 0)
          return;

      // First two entries are '.' and '..'
      visual_mem_free (namelist[0]);
      visual_mem_free (namelist[1]);

      for (int i = 2; i < n; i++) {
          std::string full_path = dir + "/" + namelist[i]->d_name;

          if (str_has_suffix (full_path, ".so")) {
              PluginRef* ref = load_plugin_ref (full_path);

              if (ref) {
                  visual_log (VISUAL_LOG_DEBUG, "Adding plugin: %s", ref->info->name);

                  list.push_back (*ref);
                  delete ref;
              }
          }

          visual_mem_free (namelist[i]);
      }

      visual_mem_free (namelist);

#endif
  }
开发者ID:Libvisual,项目名称:LibVisualAndroid,代码行数:78,代码来源:lv_plugin_registry.cpp

示例12: searchPaths

void
gfxFT2FontList::FindFonts()
{
#ifdef XP_WIN
    nsTArray<nsString> searchPaths(3);
    nsTArray<nsString> fontPatterns(3);
    fontPatterns.AppendElement(NS_LITERAL_STRING("\\*.ttf"));
    fontPatterns.AppendElement(NS_LITERAL_STRING("\\*.ttc"));
    fontPatterns.AppendElement(NS_LITERAL_STRING("\\*.otf"));
    wchar_t pathBuf[256];
    SHGetSpecialFolderPathW(0, pathBuf, CSIDL_WINDOWS, 0);
    searchPaths.AppendElement(pathBuf);
    SHGetSpecialFolderPathW(0, pathBuf, CSIDL_FONTS, 0);
    searchPaths.AppendElement(pathBuf);
    nsCOMPtr<nsIFile> resDir;
    NS_GetSpecialDirectory(NS_APP_RES_DIR, getter_AddRefs(resDir));
    if (resDir) {
        resDir->Append(NS_LITERAL_STRING("fonts"));
        nsAutoString resPath;
        resDir->GetPath(resPath);
        searchPaths.AppendElement(resPath);
    }
    WIN32_FIND_DATAW results;
    for (PRUint32 i = 0;  i < searchPaths.Length(); i++) {
        const nsString& path(searchPaths[i]);
        for (PRUint32 j = 0; j < fontPatterns.Length(); j++) { 
            nsAutoString pattern(path);
            pattern.Append(fontPatterns[j]);
            HANDLE handle = FindFirstFileExW(pattern.get(),
                                             FindExInfoStandard,
                                             &results,
                                             FindExSearchNameMatch,
                                             NULL,
                                             0);
            PRBool moreFiles = handle != INVALID_HANDLE_VALUE;
            while (moreFiles) {
                nsAutoString filePath(path);
                filePath.AppendLiteral("\\");
                filePath.Append(results.cFileName);
                AppendFacesFromFontFile(static_cast<const PRUnichar*>(filePath.get()));
                moreFiles = FindNextFile(handle, &results);
            }
            if (handle != INVALID_HANDLE_VALUE)
                FindClose(handle);
        }
    }
#elif defined(ANDROID)
    gfxFontCache *fc = gfxFontCache::GetCache();
    if (fc)
        fc->AgeAllGenerations();
    mPrefFonts.Clear();
    mCodepointsWithNoFonts.reset();

    DIR *d = opendir("/system/fonts");
    struct dirent *ent = NULL;
    while(d && (ent = readdir(d)) != NULL) {
        int namelen = strlen(ent->d_name);
        if (namelen > 4 &&
            strcasecmp(ent->d_name + namelen - 4, ".ttf") == 0)
        {
            nsCString s("/system/fonts");
            s.Append("/");
            s.Append(nsDependentCString(ent->d_name));

            AppendFacesFromFontFile(nsPromiseFlatCString(s).get());
        }
    }
    if (d) {
      closedir(d);
    }
    mCodepointsWithNoFonts.SetRange(0,0x1f);     // C0 controls
    mCodepointsWithNoFonts.SetRange(0x7f,0x9f);  // C1 controls

#endif // XP_WIN && ANDROID
}
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:75,代码来源:gfxFT2FontList.cpp

示例13: CopyFile

//////////////////////////////////////////////////////////////////////////
//参数:
//		pSrcDir [IN]	--		源, 如: D:\\aaa\\*
//		pDstDir [IN]	--		备份到哪里去, 如: E:\\bbb\\*
//
//////////////////////////////////////////////////////////////////////////
bool CFileBackUp::BackUp(const wstring& src, const wstring& dst)
{
	return CopyFile(src.c_str(), dst.c_str(), FALSE);   

	bool bRet=TRUE;   
	int iSrcFile=0;   
	int iDstFile=0;   

	TCHAR* pSrcDir = const_cast<TCHAR*>(src.c_str());
	TCHAR* pDstDir = const_cast<TCHAR*>(dst.c_str());

    //在源目录下遍历所有的文件保存在SrcFiles结构体中   
    HANDLE hFile=FindFirstFile(pSrcDir,&fd);   
    while(hFile!=INVALID_HANDLE_VALUE && bRet)   
    {   
        if(fd.dwFileAttributes==FILE_ATTRIBUTE_ARCHIVE)   
        {   
            SrcFiles[iSrcFile].fd=fd;   
            SrcFiles[iSrcFile].bIsNew=FALSE;   
            //out<<SrcFiles[iSrcFile].fd.cFileName<<endl;   
            iSrcFile++;   
        }   
        bRet=FindNextFile(hFile,&fd);   
    }   
       
    //在目标目录下遍历所有的文件保存在DstFiles结构体中   
    bRet=TRUE;   
    hFile=FindFirstFile(pDstDir,&fd);   
    while(hFile!=INVALID_HANDLE_VALUE && bRet)   
    {   
        if(fd.dwFileAttributes==FILE_ATTRIBUTE_ARCHIVE)   
        {   
            DstFiles[iDstFile].fd=fd;   
            DstFiles[iDstFile].bIsMatch=FALSE;   
            iDstFile++;   
        }   
        bRet=FindNextFile(hFile,&fd);   
    }   
///////////////////////////////////////////////////////////////    
//  下面开始比较源目录和目标目录的所有文件名称与建表时间     //   
//  找出SrcFile中那些文件比DstFile文件时间上更早,           //   
//  就讲bIsNew设为TRUE,同时DstFile文件中存在,而在SrcFile中 //   
//  不存在,就把bMatch设为False                              //   
    for(int i=0;i<iSrcFile-1;i++)   
    {   
        bool bNull=TRUE;   
        for(int j=0;j<iDstFile-1;j++)   
        {   
            if(lstrcmpi(SrcFiles[i].fd.cFileName,DstFiles[j].fd.cFileName)==0)   
            {   
                DstFiles[j].bIsMatch=TRUE;   
                bNull=FALSE;   
                if(1==CompareFileTime(&SrcFiles[i].fd.ftCreationTime,&DstFiles[j].fd.ftCreationTime))   
            //  if(SrcFiles[i].fd.ftCreationTime.dwLowDateTime > DstFiles[j].fd.ftCreationTime.dwLowDateTime)   
                    SrcFiles[i].bIsNew=TRUE;   
                break;   
            }   
        }   
        if(bNull==TRUE)   
            SrcFiles[i].bIsNew=TRUE;   
    }   
   
   
    //拷贝SrcFile中bIsNew位TRUE的文件到DstFile中去   
    for(int a=0;a<iSrcFile-1;a++)   
    {   
        if(SrcFiles[a].bIsNew)   
        {   
            CopyFile(SrcFiles[a].fd.cFileName,pDstDir,FALSE);   
        }   
    }   
       
    //删除目标中bMatch为FALSE的文件   
    for (int b=0; b<iDstFile; b++)    
    {   
        if (!DstFiles[b].bIsMatch)   
        {   
            lstrcat(pDstDir, DstFiles[b].fd.cFileName);   
            DeleteFile(pDstDir);   
            // printf("delete %s \n", dest);   
        }   
    }   
   
    return 0;
}
开发者ID:killbug2004,项目名称:DvrWorkstation,代码行数:91,代码来源:FileBackUp.cpp

示例14: recursivefullname

/* Thanks to John Bollinger <[email protected]> who has tested the
   windows part */
static char *
recursivefullname(const char *path, const char *filename, TBOOLEAN recursive)
{
    char *fullname = NULL;
    FILE *fp;

    /* length of path, dir separator, filename, \0 */
    fullname = gp_alloc(strlen(path) + 1 + strlen(filename) + 1,
			"recursivefullname");
    strcpy(fullname, path);
    PATH_CONCAT(fullname, filename);

    if ((fp = fopen(fullname, "r")) != NULL) {
	fclose(fp);
	return fullname;
    } else {
	free(fullname);
	fullname = NULL;
    }

    if (recursive) {
#ifdef HAVE_DIRENT_H
	DIR *dir;
	struct dirent *direntry;
	struct stat buf;

	dir = opendir(path);
	if (dir) {
	    while ((direntry = readdir(dir)) != NULL) {
		char *fulldir = gp_alloc(strlen(path) + 1 + strlen(direntry->d_name) + 1,
					 "fontpath_fullname");
		strcpy(fulldir, path);
#  if defined(VMS)
		if (fulldir[strlen(fulldir) - 1] == ']')
		    fulldir[strlen(fulldir) - 1] = '\0';
		strcpy(&(fulldir[strlen(fulldir)]), ".");
		strcpy(&(fulldir[strlen(fulldir)]), direntry->d_name);
		strcpy(&(fulldir[strlen(fulldir)]), "]");
#  else
		PATH_CONCAT(fulldir, direntry->d_name);
#  endif
		stat(fulldir, &buf);
		if ((S_ISDIR(buf.st_mode)) &&
		    (strcmp(direntry->d_name, ".") != 0) &&
		    (strcmp(direntry->d_name, "..") != 0)) {
		    fullname = recursivefullname(fulldir, filename, TRUE);
		    if (fullname != NULL)
			break;
		}
		free(fulldir);
	    }
	    closedir(dir);
	}
#elif defined(_Windows)
	HANDLE filehandle;
	WIN32_FIND_DATA finddata;
	char *pathwildcard = gp_alloc(strlen(path) + 2, "fontpath_fullname");

	strcpy(pathwildcard, path);
	PATH_CONCAT(pathwildcard, "*");

	filehandle = FindFirstFile(pathwildcard, &finddata);
	free(pathwildcard);
	if (filehandle != INVALID_HANDLE_VALUE)
	    do {
		if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
		    (strcmp(finddata.cFileName, ".") != 0) &&
		    (strcmp(finddata.cFileName, "..") != 0)) {
		    char *fulldir = gp_alloc(strlen(path) + 1 + strlen(finddata.cFileName) + 1,
					     "fontpath_fullname");
		    strcpy(fulldir, path);
		    PATH_CONCAT(fulldir, finddata.cFileName);

		    fullname = recursivefullname(fulldir, filename, TRUE);
		    free(fulldir);
		    if (fullname != NULL)
			break;
		}
	    } while (FindNextFile(filehandle, &finddata) != 0);
	FindClose(filehandle);

#else
	int_warn(NO_CARET, "Recursive directory search not supported\n\t('%s!')", path);
#endif
    }
    return fullname;
}
开发者ID:easeip,项目名称:GnuPlot-OSX,代码行数:89,代码来源:misc.c

示例15: DI_list


//.........这里部分代码省略.........
	/* Check input parameters */

	if ((pathlength > DI_PATH_MAX) ||
	    (pathlength == 0))
		return DI_BADPARAM;

	/* get null terminated path to the directory */

	memcpy(input_path, path, pathlength);
	memcpy(input_path + pathlength, "\\*.*", 5);

	/* break out on errors */

	while ( (handle = FindFirstFile(input_path, &findbuf)) == 
		INVALID_HANDLE_VALUE )
	{
		switch (dos_call = GetLastError()) 
		{
            	case ERROR_NO_SYSTEM_RESOURCES:
                case ERROR_TOO_MANY_OPEN_FILES:
                case ERROR_NO_MORE_FILES:
                case ERROR_NOT_ENOUGH_MEMORY:
                case ERROR_OUTOFMEMORY:
                case ERROR_HANDLE_DISK_FULL:
                case ERROR_OUT_OF_STRUCTURES:
                case ERROR_NONPAGED_SYSTEM_RESOURCES:
                case ERROR_PAGED_SYSTEM_RESOURCES:
            		if (DIlru_flush( err_code ) != OK)
            		{
                	    ret_val = DI_BADLIST;
            		}
			else
			{
			    continue;
			}
                	break;
		case ERROR_PATH_NOT_FOUND:
			SETWIN32ERR(err_code, dos_call, ER_list);
			ret_val = DI_DIRNOTFOUND;
			break;
		default:
			SETWIN32ERR(err_code, dos_call, ER_list);
			ret_val = DI_BADLIST;
			break;
		}
		if ( ret_val != OK )
		    return(ret_val);
	}

	/* now loop through all entries in the directory */

	ret_val = DI_ENDFILE;

	do {
		if (!memcmp(findbuf.cFileName, ".", 2) ||
		    !memcmp(findbuf.cFileName, "..", 3)) 
		{
			continue;
		}

		/*
		 * This next check is a leftover from OS/2.  Should dump it
		 * at some point, or enlarge the functionality of this
		 * routine. If we're looking for a directory, verify it is
		 * one...
		 */

		if (list_type == DIRECTORY) 
		{
			if (~findbuf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
				continue;
			}
		}

		/* 
		* other functions expect lowercase name, but DOS
		* returns uppercase
                *
                * bug fix 89213.  
                * Unlike DOS, NT returns upper and lower case
                * names.
		*/
		if ((*func) (arg_list,
		             findbuf.cFileName,
		             STlength(findbuf.cFileName),
		             err_code)) 
		{
			ret_val = DI_ENDFILE;
			break;
		}
	} while (FindNextFile(handle, &findbuf));

	if (!FindClose(handle)) 	
	{
		SETWIN32ERR(err_code, GetLastError(), ER_list);
		ret_val = DI_BADLIST;
	}

	return (ret_val);
}
开发者ID:saqibjamil,项目名称:Ingres,代码行数:101,代码来源:dilist.c


注:本文中的FindNextFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。