5 /* Defino las extenciones que usan cada tipo de archivo */
6 #define EXT_TIPO3_ID ".id3"
7 #define EXT_TIPO3_DATA ".dat"
8 #define EXT_TIPO3_DISP ".fsc"
9 #define EXT_TIPO3_IDS ".idc"
10 #define EXT_TIPO3_EXTRA ".ids"
12 char *str_dup(const char *s)
14 if (s == NULL) return NULL;
15 char *tmp = (char *)malloc(sizeof(char)*(strlen(s)+1));
21 EMUFS *emufs_crear(const char *filename, char tipo, unsigned int tam_bloque, unsigned int tam_reg)
25 EMUFS *tmp = (EMUFS *)malloc(sizeof(EMUFS));
34 tmp->tam_bloque = tam_bloque;
35 tmp->leer_bloque = leer_bloque;
36 tmp->leer_registro = leer_registro;
37 tmp->grabar_registro = grabar_registro;
38 tmp->borrar_registro = NULL;
39 tmp->nombre = str_dup(filename);
41 strcpy(name, filename);
42 strcat(name, EXT_TIPO3_DATA);
43 fp = fopen(name, "w");
50 /* Guardo el Header */
51 fwrite(&tipo, sizeof(char), 1, fp);
52 fwrite(&tam_bloque, sizeof(unsigned int), 1, fp);
53 fwrite(&tam_reg, sizeof(unsigned int), 1, fp);
56 strcpy(name, filename);
57 strcat(name, EXT_TIPO3_ID);
58 fp = fopen(name, "w");
61 strcpy(name, filename);
62 strcat(name, EXT_TIPO3_DISP);
63 fp = fopen(name, "w");
66 strcpy(name, filename);
67 strcat(name, EXT_TIPO3_IDS);
68 fp = fopen(name, "w");
71 strcpy(name, filename);
72 strcat(name, EXT_TIPO3_EXTRA);
73 fp = fopen(name, "w");
85 int emufs_destruir(EMUFS *e)
87 if (e == NULL) return 1;