Exemplo n.º 1
0
void CPpcMainWnd::OnFileSort(UINT uID)
{
	int nSort = SORTFILE_BYNAME;
	switch (uID) {
		case IDM_FILE_SORT_BYNAME:
			nSort = SORTFILE_BYNAME; break;
		case IDM_FILE_SORT_BYPATH:
			nSort = SORTFILE_BYPATH; break;
	}
	SortFile(nSort);
}
Exemplo n.º 2
0
extern void SortCurrent( sio_data * curr_sio )
/********************************************/
{
    if( curr_sio->level_open == LEVEL_SAMPLE ) {
        SortImage( curr_sio );
    } else if( curr_sio->level_open == LEVEL_IMAGE ) {
        SortMod( curr_sio );
    } else if( curr_sio->level_open == LEVEL_MODULE ) {
        SortFile( curr_sio );
    } else if( curr_sio->level_open == LEVEL_FILE ) {
        SortRtn( curr_sio );
    }
}
Exemplo n.º 3
0
int main(int argc, char *argv[]) {
	//Bits for flags: d|f|t
	int flags = 0;

	char searchStr[STRLEN] = {0};
	char fileName[STRLEN] = {0};
	char termChar = '\0';

	//Check for proper number of args
	if (argc <= 1 || argc > 6) {
		printf("usage: look [-df] [-t char] string [file ...]\n");
		exit(1);
	}

	ParseArgs(argc, argv, &flags, searchStr, fileName, &termChar);

	if (strlen(fileName) > 0) {
		if (open(fileName, O_RDONLY) == -1) {
			printf("file open failed\n");
			exit(1);
		}

		SortFile(fileName, flags);
	}
	else {
		if (open("/usr/share/dict/words", O_RDONLY) == -1) {
			printf("file open dictionary failed\n");
		}

		SortFile("/usr/share/dict/words", flags); 
	}

	FindString(searchStr, flags, termChar);

	return 0;

}
Exemplo n.º 4
0
std::string SortFile::ComputeSorting(part ind)
{
	std::string filename=ind.fileName;
	std::ifstream file_old(filename.c_str());
	std::string sorted_file_name=filename.substr(0,filename.find(".int"))+ "_sorted"+".int";
	std::ofstream fileSorted(sorted_file_name.c_str());
	if(fileSorted.is_open())
		fileSorted<<"h_ID chr hap st en hap_index root_pop"<<"\n";
	else
	{
		std::cerr<<" Error Opening Sorted File "<<sorted_file_name<<std::endl;
		exit(0);
	}
    std::vector<SortFile> columns;
    std::string every;
    int count=0;
    while(getline(file_old,every))
		{
			std::stringstream ss;
			if (!strcmp("h_ID chr hap st en hap_index root_pop",every.c_str()))	/*Correct .int file is opened*/
					continue;
			ss<<every;
			ss>>ind.h_ID;	/*get the h_ID i..e the name of the individual from .int file*/
			ss>>ind.chr;
			ss>>ind.hap;
			ss>>ind.st;
			ss>>ind.en;
			ss>>ind.hap_index;
			ss>>ind.root_pop;
			ss.str("");
			ss.clear();	/*Clear state flags*/
			//std::cout<<ind.h_ID<<"	" <<ind.chr<<"	"<<ind.hap<<"	"<<ind.st<<"	"<<ind.en<<"	"<<ind.hap_index<<"	"<<ind.root_pop<<std::endl;
			columns.push_back(SortFile(ind.h_ID, ind.chr, ind.hap,ind.st,ind.en,ind.hap_index,ind.root_pop));
			//getchar();
		}
    std::sort(columns.begin(), columns.end(), byY());
    for(std::vector<SortFile>::iterator it = columns.begin(); it != columns.end(); ++it)
    	fileSorted<<*it<<"\n";
    file_old.close();
    fileSorted.close();
    return sorted_file_name;
}