示例#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;
}
示例#2
0
  void FirstGreyScale::Execute()
  {
      Mat image;
      image = imread(_filename);
      
      if (image.empty())
      {	  
	  throw IOException(_filename);
      }
            
      Mat grayImage;
      cvtColor(image, grayImage, COLOR_BGR2GRAY);
                  
      namedWindow("Input Image", WINDOW_AUTOSIZE );      
      namedWindow("Converted Image", WINDOW_AUTOSIZE );
      
      if (_enableOutput) {
	string grayFilename = AppendFilename(_filename, "_gray");
	cout << "Grayscale filename: " << grayFilename << endl;      
	imwrite( grayFilename.c_str(), grayImage );
      }
      
      imshow("Input Image", image);                        
      imshow("Converted Image", grayImage);            
  }
示例#3
0
int	FindNextFile(DIR *pDir, DIRENT *pFindData) {
	struct dirent *pDirent = readdir(pDir);

	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 1;
		}		
		if(wildcompare(pFindData->szWildCard, pDirent->d_name)) {
			AppendFilename(pFindData->szItemPath, pDirent->d_name);
			lstat(pFindData->szItemPath, &pFindData->itemInfo);
			memcpy(&pFindData->dir, pDirent, sizeof(struct dirent));
			return 1;			
		}
		pDirent = readdir(pDir);
	}

	return 0;
}
示例#4
0
static int copy_dir(const char *srcPath, const char *destPath, FF_T_BOOL bRecursive, FF_T_BOOL bVerbose, FF_ENVIRONMENT *pEnv) {
	FF_DIRENT	findData;
	FF_ERROR	RetVal;
	FF_T_INT8	szsrcFile[FF_MAX_PATH], szdestFile[FF_MAX_PATH];

	//const char	*szpWildCard;
	int i;

	strcpy(szsrcFile, srcPath);
	strcpy(szdestFile, destPath);

	// Ensure the paths both end in a '/' charachter
	i = strlen(szsrcFile);
	if(szsrcFile[i - 1] != '\\' || szsrcFile[i - 1] != '/') {
		strcat(szsrcFile, "\\");
	}
	i = strlen(szdestFile);
	if(szdestFile[i - 1] != '\\' || szdestFile[i - 1] != '/') {
		strcat(szdestFile, "\\");
	}

	RetVal = FF_FindFirst(pEnv->pIoman, &findData, szsrcFile);

	if(RetVal) {
		printf("cp: %s: No such file or directory.\n", srcPath);
		return 0;
	}

	while(!RetVal) {
		AppendFilename(szsrcFile, findData.FileName);
		AppendFilename(szdestFile, findData.FileName);

		if(!strcmp(szsrcFile, szdestFile)) {
			printf("cp: Source and Destination files are identical: illegal operation.\n");
			return 0;
		}

		if((findData.Attrib & FF_FAT_ATTR_DIR)) {
			if(!(findData.FileName[0] == '.' && !findData.FileName[1]) && !(findData.FileName[0] == '.' && findData.FileName[1] == '.' && !findData.FileName[2])) {
				// Add the wild card onto the end!
				if(bRecursive) {
					strcat(szsrcFile, "\\");
					//szpWildCard = getWildcard(srcPath);
					//strcat(szsrcFile, szpWildCard);
					
					strcat(szdestFile, "\\");
					//szpWildCard = getWildcard(destPath);
					//strcat(szdestFile, szpWildCard);
					

					// Make the dir if it doesn't already exist!
					copy_dir(szsrcFile, szdestFile, bRecursive, bVerbose, pEnv);

					strcpy(szsrcFile, srcPath);		// Reset the path.
				}
			}
		} else {
			copy_file(szsrcFile, szdestFile, bVerbose, pEnv);
		}

		RetVal = FF_FindNext(pEnv->pIoman, &findData);
	}

	return 0;
}
void FGetRevisionTest::GetTests(TArray<FString>& OutBeautifiedNames, TArray<FString>& OutTestCommands) const
{
	GetProviders(OutBeautifiedNames, OutTestCommands);
	AppendFilename(TEXT("/Engine/EditorAutomation/SourceControlTest"), OutBeautifiedNames, OutTestCommands);
}
void FGetLabelTest::GetTests(TArray<FString>& OutBeautifiedNames, TArray<FString>& OutTestCommands) const
{
	GetProviders(OutBeautifiedNames, OutTestCommands);
	AppendFilename(TEXT("SourceControlAutomationLabel"), OutBeautifiedNames, OutTestCommands);
}
void FUpdateStatusTest::GetTests(TArray<FString>& OutBeautifiedNames, TArray<FString>& OutTestCommands) const
{
	GetProviders(OutBeautifiedNames, OutTestCommands);
	AppendFilename(TEXT("/Engine/NotForLicensees/Automation/EditorAutomation/SourceControlTest"), OutBeautifiedNames, OutTestCommands);
}
示例#8
0
/**
 *	@public
 *	@brief	MD5 Data Hashing function.
 *
 *	Generates and displays an MD5 hash of a file. This is really useful when
 *	verify files for their integrity. We used MD5 extensively while stabilising
 *	the read and write functionality of FullFAT.
 *
 **/
int md5sum_lin_cmd(int argc, char **argv) {
    int option;
    FFT_GETOPT_CONTEXT	optionContext;
    FF_T_BOOL			bBinary = FF_FALSE, bCheck = FF_FALSE, bWarn = FF_FALSE;
    DIRENT 				findData;
    DIR					*pDir;
    FILE				*pfOut;

    //FF_ERROR			RetVal, ffError;
    int					RetVal;
    char				path[FF_MAX_PATH];
    char				outfilepath[FF_MAX_PATH];
    const char			*szargPath;
    char				hash[33];

    const char			*szargOutputFile = NULL;
    int i;

    memset(&optionContext, 0, sizeof(FFT_GETOPT_CONTEXT));

    option = FFTerm_getopt(argc, argv, "bctwo:", &optionContext);

    if(option != EOF) {
        do {
            switch(option) {
            case 'b':
                bBinary = FF_TRUE;
                break;
            case 'c':
                bCheck = FF_TRUE;
                break;

            case 't':
                bBinary = FF_FALSE;
                break;

            case 'w':
                bWarn = FF_TRUE;
                break;

            case 'o':
                szargOutputFile = optionContext.optarg;
                break;
            }

            option = FFTerm_getopt(argc, argv, "bctw", &optionContext);
        } while(option != EOF);
    }

    szargPath = FFTerm_getarg(argc, argv, 0, &optionContext);	// Get the available non-option arguments remaining.

    if(szargPath) {
        ProcessLinuxPath(path, szargPath);
        //strcpy(path, szargPath);
        //RetVal = FF_FindFirst(pEnv->pIoman, &findData, path);


        if(szargOutputFile) {
            ProcessLinuxPath(outfilepath, szargOutputFile);
            //pfOut = FF_Open(pEnv->pIoman, outfilepath, FF_MODE_WRITE | FF_MODE_TRUNCATE | FF_MODE_CREATE, &ffError);
            //strcpy(outfilepath, szargOutputFile);
            pfOut = fopen(outfilepath, "w");
            if(!pfOut) {
                printf("%s: Error opening %s for writing.\n", argv[0], szargOutputFile);
                return 0;
            }
        }

        pDir = FindFirstFile(path, &findData);

        if(!pDir) {
            printf("%s: %s: No such file or directory.\n", argv[0], szargPath);
            return 0;
        }

        do {
            if(S_ISDIR(findData.itemInfo.st_mode)) {
                printf("%s: %s: Is a directory\n", argv[0], findData.dir.d_name);
            } else {
                AppendFilename(path, findData.dir.d_name);
                if(!bCheck) {
                    if(!md5_getHash(path, hash)) {
                        printf("%s  %s\n", hash, findData.dir.d_name);
                    }

                    if(szargOutputFile && strcmp(szargOutputFile, findData.dir.d_name)) {
                        for(i = 0; i < 32; i++) {
                            //FF_PutC(pfOut, hash[i]);
                            fputc(hash[i], pfOut);
                        }
                        //FF_PutC(pfOut, ' ');
                        //FF_PutC(pfOut, ' ');
                        fputc(' ', pfOut);
                        fputc(' ', pfOut);
                        for(i = 0; findData.dir.d_name[i] != '\0'; i++) {
                            //FF_PutC(pfOut, findData.FileName[i]);
                            fputc(findData.dir.d_name[i], pfOut);
                        }
                        //FF_PutC(pfOut, '\n'); // Nextline!
                        fputc('\n', pfOut);
                    }

                } else {
                    md5_checkHash(path);
                }
            }
            //RetVal = FF_FindNext(pEnv->pIoman, &findData);
            //RetVal = FindNextFileA(hSearch, &findData);
            RetVal = FindNextFile(pDir, &findData);
        } while(RetVal);

        if(szargOutputFile) {
            //FF_Close(pfOut);
            fclose(pfOut);
        }

        if(pDir) {
            FindClose(pDir);
        }

        return 0;
    }

    printf("See usage! -- Please!\n");

    return 0;
}