Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "interface.h"
- static int one(struct dirent *unused){
- return 1;
- }
- /****************************************
- * Busca arquivo passado como paramentro
- * na lista de arquivos
- ***************************************/
- int fexists(char *file, struct dirent **eps, int n){
- int i;
- for(i=0; i < n; i++)
- if(!strcmp(file, eps[i]->d_name))
- return 1;
- return 0;
- }
- //opcao para o usuario escolher arquivo
- void user_option(){
- struct dirent **eps;
- int n;
- char file[20];
- //armazena nomes de arquivos do diretorio
- n = scandir ("./", &eps, one, alphasort);
- printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
- printf("\t\tArquivos locais:\n");
- printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
- if (n >= 0){
- int cnt;
- for(cnt = 0; cnt < n; ++cnt)
- if(cnt%2==0)
- printf("%s\n", eps[cnt]->d_name);
- }
- else
- perror("Couldn't open the directory");
- printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
- printf("\n\nQual arquivo deseja consultar? ");
- scanf("%s", file);
- if( fexists(file, eps, n) )
- printf("\nArquivo %s esta presente no diretorio corrente.\n", file);
- else
- printf("\nArquivo nao esta presente. Busca deve ser iniciada.\n");
- }
Add Comment
Please, Sign In to add comment