Пример #1
0
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    CFileFinder	_finder;
    CString csDirectorioEntrada;
    CString csFicheroSalida;

	if ( procesa_argumentos(argc, argv,csDirectorioEntrada,csFicheroSalida) == false)		
		return 1;

    //Abrir fichero de salida
	FILE*   archivo;
	if ((archivo = fopen(csFicheroSalida, "wt")) == NULL)
		return 1;

    // Dejar espacio para resumen posterior
    fseek(archivo,153 + 7*2,SEEK_SET);


    // Buscar todos los archivos de datos
	CFileFinder::CFindOpts	opts;
	// Set CFindOpts object
	opts.sBaseFolder = csDirectorioEntrada;
	opts.sFileMask.Format("*.dat");
	opts.bSubfolders = true;
	opts.FindNormalFiles();
	_finder.RemoveAll();
	_finder.Find(opts);
    // Fin de la busqueda

    // Para cada archivo, leer la informacion y volcarla al fichero general
    CString csFichero;
    int nValidFileCount = 0;
    int nValidAreaCount = 0;
    int nAreasInFile = -1;
    int num_bandas = 0;
    for (int i=0 ; i<_finder.GetFileCount();i++)
    {
        csFichero = _finder.GetFilePath(i);
        nAreasInFile = ProcesarFichero(csFichero, archivo, nValidAreaCount, num_bandas); //nValidAreaCount se incrementa
        if (nAreasInFile > 0)
        {
            nValidFileCount++;
        }
    }

    // Añadir resumen a archivo de salida
    fseek(archivo,0,SEEK_SET);
    fprintf(archivo, "# Información de reflectancia de todos los minerales\n");
    // Añadir fecha
    SYSTEMTIME st;
    GetSystemTime(&st);
    fprintf(archivo,"# %2d del %2d de %4d a las %2d:%2d\n" ,st.wDay,st.wMonth,st.wYear,st.wHour,st.wMinute);
    fprintf(archivo, "# Numero total de ficheros usados: %4d\n",nValidFileCount);
    fprintf(archivo, "\n");
    fprintf(archivo, "num_datos = %4d\n",nValidAreaCount);
    fprintf(archivo, "num_bandas = %2d\n",num_bandas);
    fprintf(archivo, "\n");

	return 0;
}
//Leemos el fichero de informacion de barrido del directorio elegido y mostramos la informacion de barrido
bool LeerInfoBarrido(CString csDirectorio)
{
    //Primero, debemos buscar el fichero de informacion (no sabemos como se llama porque no sabemos cual
    CFileFinder	_finder;
    CString csExtInfoBarrido = "_INFO_BARRIDO.txt";

	CFileFinder::CFindOpts	opts;
	opts.sBaseFolder = csDirectorio;
	opts.sFileMask.Format("*" + csExtInfoBarrido);
	opts.bSubfolders = false;
	opts.FindNormalFiles();
	_finder.RemoveAll();
	_finder.Find(opts); //Busqueda

    CString csFichero;
    CString csError;

    if (_finder.GetFileCount() <1) return false; //no hay informacion de barrido

    csFichero = _finder.GetFilePath(0);
    if (_finder.GetFileCount() > 1)
        printf("ATENCION: se han encontrado varios archivos de información de barrido, se usará %s", csFichero);

    //Lee el fichero
    FILE* f_info_barrido = fopen(csFichero, "rt");

    char strDummy[500]; //para saltarse la cabecera
//    fscanf(f_info_barrido,"%[^\n]",strDummy); //cabecera
    fgets(strDummy,500,f_info_barrido);
    fscanf(f_info_barrido,"%dx%d",&g_nCampos_x,&g_nCampos_y);
    fscanf(f_info_barrido,"%d",&g_nBandas);
    for (int b=0;b<g_nBandas;b++)
        fscanf(f_info_barrido,"%d\t",&g_arrFiltros[b]); //se leen los filtros (1..N) correspondientes a cada banda

    fclose(f_info_barrido);

    g_csMuestra = csFichero.Mid(csDirectorio.GetLength(), csFichero.GetLength() - csDirectorio.GetLength() - csExtInfoBarrido.GetLength());

    return true;   
}
Пример #3
0
void COutputTabView::FindInFiles(CString text, CString folder, CString mask, bool subfolder, bool size, int nmin, int nmax ) 
{
		
	if (_bSearching)
	{
		_finder.StopSearch();
		return;
	}

	CFileFinder::CFindOpts	opts;

	// Set CFindOpts object
	opts.sBaseFolder = folder;
	opts.sFileMask.Format(_T("*%s*"), mask);
	opts.bSubfolders = subfolder;
	opts.FindNormalFiles();

	if (size)
	{
		opts.dwOptionsFlags |= FIND_SIZE;
		opts.nMinSize = (__int64)nmin * (__int64)1024;
		opts.nMaxSize = (__int64)nmax * (__int64)1024;
	}

	if (!text.IsEmpty())
	{
		opts.FindText(text);
	}

	m_listCtrl3.DeleteAllItems();
		

	_bSearching = true;
	_finder.RemoveAll();
	_finder.Find(opts);
	_bSearching = false;

	
}