-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainDescompacta.c
52 lines (40 loc) · 1.2 KB
/
mainDescompacta.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
*
* TAD REFERENTE AO TRABALHO DA DISCIPLINA DE ESTRUTURA DE DADOS I
* COMPACTADOR DE HUFFMAN
*
* ALUNAS: BARBARA ALENCAR DE ARAUJO PEREIRA E MARIA EDUARDA NOIA MATTOS DE AZEVEDO
*
* MAIN DESCOMPACTA: RESPONSÁVEL PELA CHAMADA DAS FUNÇÕES DE DESCOMPACTAÇÃO E A GERAÇÃO DO ARQUIVO ANÁLOGO AO ORIGINAL A PARTIR DO COMPACTADO .COMP
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "arvore.h"
#include "lista.h"
#include "descompactador.h"
#include "bitmap.h"
#define TAM_NOME_CAMINHO 300
#define TAM_ASCII 256
#define MEGA_BYTE 1024 * 1024
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Uso: %s <nome_arquivo>\n", argv[0]);
return 0;
}
char caminhoEntrada[TAM_NOME_CAMINHO];
strncpy(caminhoEntrada, argv[1], TAM_NOME_CAMINHO - 1);
int tam = strlen(caminhoEntrada);
unsigned char caminhoSaida[tam];
strcpy(caminhoSaida, caminhoEntrada);
caminhoSaida[tam - 5] = '\0';
FILE *compactado = fopen(caminhoEntrada, "rb");
if(!compactado) {
printf("Nao foi possivel abrir o arquivo compactado!\n");
return 0;
}
descompactaArquivo(compactado, caminhoSaida);
fclose(compactado);
return 0;
}