Guest User

Untitled

a guest
Sep 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. int Iso9660_abrir_arquivo(unsigned char * path, unsigned char **imagem)
  2. {
  3. int encontrou = 0;
  4.  
  5. //recuperar diretório raiz
  6. unsigned char *dir;
  7. unsigned int tamanho;
  8. Cdir *dir_aux;
  9. Iso9660_carregar_info_disco();
  10. Iso9660_recuperar_diretorio(&dir,"");
  11.  
  12. char * trecho = strtok(path, "/");
  13.  
  14. while(trecho != NULL)
  15. {
  16.  
  17. unsigned pos = 0;
  18. encontrou = 0;
  19.  
  20. while(dir[pos] > 0)
  21. {
  22. dir_aux = (Cdir*)&dir[pos];
  23.  
  24. char nome[256];
  25. memset(nome,'\0',sizeof(nome));
  26.  
  27. for(int aux = 0; aux < dir_aux->namelen; aux++)
  28. {
  29. if( dir_aux->name[aux] != ';')
  30. {
  31. nome[aux] = dir_aux->name[aux];
  32. }
  33. else
  34. {
  35. nome[aux] = '\0';
  36. }
  37.  
  38. }
  39.  
  40.  
  41. if(!strcmp(trecho, nome))
  42. {
  43. Iso9660_recuperar_arquivo(&dir,*(unsigned int*)dir_aux->dloc,*(unsigned int*)dir_aux->dlen);
  44. encontrou = 1;
  45. tamanho = *(unsigned int*)dir_aux->dlen;
  46. break;
  47. }
  48.  
  49. pos+= (unsigned int)dir[pos];
  50. }
  51.  
  52. if(!encontrou) return -1;
  53.  
  54. trecho = strtok(NULL, "/");
  55.  
  56. }
  57.  
  58. *imagem = dir;
  59. return tamanho;
  60. }
Add Comment
Please, Sign In to add comment