Esempio n. 1
0
DIR	*FindFirstFile(const char *szpPath, DIRENT *pFindData) {
	DIR 			*pDir;
	struct dirent 	*pDirent;
	const char		*szpWildCard;
	char			path[FF_MAX_PATH];

	strcpy(pFindData->szWildCard, "");
	szpWildCard = GetWildcard(szpPath);
	strcpy(pFindData->szWildCard, szpWildCard);

	strncpy(path, szpPath, (szpWildCard - szpPath));
	path[(szpWildCard - szpPath)] = '\0';

	pDir = opendir(path);

	if(!pDir) {
		return NULL;
	}

	pDirent = readdir(pDir);

	strcpy(pFindData->szItemPath, path);
	
	while(pDirent) {
		if(!strcmp(pFindData->szWildCard, "")) {
			AppendFilename(pFindData->szItemPath, pDirent->d_name);
			lstat(pFindData->szItemPath, &pFindData->itemInfo);
			memcpy(&pFindData->dir, pDirent, sizeof(struct dirent));
			return pDir;
		}
		
		if(pDirent->d_name[0] == 'P') {
			printf(" ");
		}

		if(wildcompare(szpWildCard, pDirent->d_name)) {
			AppendFilename(pFindData->szItemPath, pDirent->d_name);
			lstat(pFindData->szItemPath, &pFindData->itemInfo);
			memcpy(&pFindData->dir, pDirent, sizeof(struct dirent));
			return pDir;			
		}
		pDirent = readdir(pDir);
	}

	closedir(pDir);

	return NULL;
}
Esempio n. 2
0
void wxFileDialog::SetWildcard(const wxString& wildCard)
{
    wxFileDialogBase::SetWildcard(wildCard);
    m_fc.SetWildcard( GetWildcard() );
}
Esempio n. 3
0
int cp_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
#ifdef FF_UNICODE_SUPPORT
	const wchar_t			*szpSource, *szpDestination, *szpWildCard;
#else
	const char			*szpSource, *szpDestination, *szpWildCard;
#endif
	char				szsrcPath[FF_MAX_PATH], szdestPath[FF_MAX_PATH];
	FF_DIRENT			findData;
	
	FFT_GETOPT_CONTEXT	optionContext;	// CommandLine processing
	FF_T_BOOL			bRecursive = FF_FALSE, bVerbose = FF_FALSE;	// Option Flags.
	int 				option;

	memset(&optionContext, 0, sizeof(FFT_GETOPT_CONTEXT));			// Initialise the option context to zero.

	option = FFTerm_getopt(argc, (const char **) argv, "rRvx", &optionContext);		// Get the command line option charachters.

	while(option != EOF) {											// Process Commandline options
		switch(option) {
			case 'r':
			case 'R':
				bRecursive = FF_TRUE;								// Set recursive flag if -r or -R appears on the commandline.
				break;

			case 'v':
				bVerbose = FF_TRUE;									// Set verbose flag if -v appears on the commandline.
				break;

			case 'x':
				bExternal = FF_TRUE;
				break;

			default:
				break;
		}

		option = FFTerm_getopt(argc, (const char **) argv, "rRvx", &optionContext);	// Get the next option.
	}

	szpSource 		= FFTerm_getarg(argc, (const char **) argv, 0, &optionContext);	// The remaining options or non optional arguments.
	szpDestination 	= FFTerm_getarg(argc, (const char **) argv, 1, &optionContext);	// getarg() retrieves them intelligently.
	
	if(!szpSource) {
		printf("%s: No source file argument.\n", argv[0]);			// No source file provided.
		return 0;
	}

	if(!szpDestination) {
		printf("%s: No destination file argument.\n", argv[0]);		// No destination provided.
		return 0;
	}

	ProcessPath(szsrcPath, szpSource, pEnv);						// Process the paths into absolute paths.
	ProcessPath(szdestPath, szpDestination, pEnv);

	szpWildCard = GetWildcard(szpSource);							// Get the last token of the source path. (This may include a wildCard).

	if(strchr(szpWildCard, '*')) {									// If the 'WildCard' contains a * then its a wild card, otherwise its a file or directory.
		// WildCard Copying!
		//copy_wild();
		return 0;
	}

	if(FF_FindFirst(pEnv->pIoman, &findData, szsrcPath)) {			// Get the dirent for the file or directory, to detect if its a directory.
		// Not found!
		printf("%s: %s: no such file or directory.\n", argv[0], szpSource);
		return 0;
	}

	if(!strcmp(findData.FileName, szpWildCard) && (findData.Attrib & FF_FAT_ATTR_DIR)) {
		if(!bRecursive) {											// Its a dir!
			printf("%s: omitting directory '%s'\n", argv[0], szsrcPath);
			return 0;
		}
		copy_dir(szsrcPath, szdestPath, bRecursive, bVerbose, pEnv);// Start the copying!
		return 0;
	}

	copy_file(szsrcPath, szdestPath, bVerbose, pEnv);				// Final option, its simply a file to file copy
	
	return 0;
}
Esempio n. 4
0
  // returns a named wildcard
string t_regexp::GetWildcard (const string& sName) const
  {
  int iNumber = PCRE_ERROR_NOSUBSTRING;
  if (IsStringNumber (sName))
    iNumber = atoi (sName.c_str ());
  else
    {
    if (m_program == NULL)
      iNumber = PCRE_ERROR_NOSUBSTRING;
    else
      {
      /* now do named subpatterns  */
      int namecount;
      pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMECOUNT, &namecount);


      if (namecount > 0)
        {
        int name_entry_size;
        unsigned char *tabptr;
        int ncapt;
        int jchanged;
        pcre_fullinfo(m_program, m_extra, PCRE_INFO_CAPTURECOUNT, &ncapt);
        pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMETABLE, &tabptr);
        pcre_fullinfo(m_program, m_extra, PCRE_INFO_NAMEENTRYSIZE, &name_entry_size);
        pcre_fullinfo(m_program, m_extra, PCRE_INFO_JCHANGED, &jchanged);
        set<string> found_strings;
        for (int i = 0; i < namecount; i++, tabptr += name_entry_size) 
          {
          int n = (tabptr[0] << 8) | tabptr[1];
          const unsigned char * name = tabptr + 2;
          if (strcmp (sName.c_str (), (LPCTSTR) name) != 0)  // skip if wrong name
             continue;
          // if duplicates were possible then ...
          if (jchanged)
            {
            // this code is to ensure that we don't find a match (eg. mob = Kobold)
            // and then if duplicates were allowed, replace Kobold with false.

            string sName = (LPCTSTR) name;

            // for duplicate names, see if we already added this name
            if (found_strings.find (sName) != found_strings.end ())
              {
              // do not replace if this one is out of range or empty
              if (n < 0 || n > m_iCount || GetWildcard (n) == "")
                continue;
              } // end of duplicate
            else
              found_strings.insert (sName);
            }

          if (n >= 0 && n <= m_iCount) 
            iNumber = n;
      
          }   // end of wildcard loop
        } // end of having named wildcards

      } // end of program not NULL

    }   // end of wanting a named wildcard
  return GetWildcard (iNumber);
  } // end of t_regexp::GetWildcard