All pastes #128231 Raw Edit

Miscellany

public text v1 · immutable
#128231 ·published 2006-08-12 20:33 UTC
rendered paste body
int dir(const char *szDir, bool bCountHidden)
{
    
	char path[MAX_PATH];
	WIN32_FIND_DATA fd;
	DWORD dwAttr = FILE_ATTRIBUTE_DIRECTORY;
	if( !bCountHidden) dwAttr |= FILE_ATTRIBUTE_HIDDEN;
	sprintf( path, "%s\\*", szDir);
	HANDLE hFind = FindFirstFile( path, &fd);

        int count = 0;
        while(hFind != INVALID_HANDLE_VALUE)  {
	   
            RegEx Pattern("SoftToken licens (\\d+)\\-(\\d+)");
    		if(Pattern.Search(fd.cFileName) == 1)
    		{
               int low = atoi ( Pattern.Match(1) );
               int high = atoi ( Pattern.Match(2) );
               if ((((key-low)+low)<=high)&&(((key-low)+low)>=low))
               {
                  int len = strlen(fd.cFileName); 
                  map = new char[len + 1]; 
                  memcpy(map, fd.cFileName, len+1);
                  FindClose( hFind);
                  return 1;
               }
               
            }

        FindClose( hFind);
        if(!FindNextFile( hFind, &fd)) break;
     }
      
    return -1;
}