-
#include "emufs.h"
#include "param_cte.h"
/* Defino las extenciones que usan cada tipo de archivo */
-#define EXT_TIPO3_ID ".id3"
+#define EXT_TIPO3_ID ".idx"
#define EXT_TIPO3_DATA ".dat"
#define EXT_TIPO3_DISP ".fsc"
-#define EXT_TIPO3_IDS ".idc"
-#define EXT_TIPO3_EXTRA ".ids"
+#define EXT_TIPO3_IDS ".ids"
+
+char *str_dup(const char *s);
char *str_dup(const char *s)
{
+ char *tmp;
if (s == NULL) return NULL;
- char *tmp = (char *)malloc(sizeof(char)*(strlen(s)+1));
+ tmp = (char *)malloc(sizeof(char)*(strlen(s)+1));
strcpy(tmp, s);
return tmp;
}
strcat(name, EXT_TIPO3_IDS);
fp = fopen(name, "w");
fclose(fp);
-
- strcpy(name, filename);
- strcat(name, EXT_TIPO3_EXTRA);
- fp = fopen(name, "w");
- fclose(fp);
+
break;
default:
free(tmp);
strcpy(name, filename);
strcat(name, EXT_TIPO3_DATA);
+
+ /* Trato de determinar el tipo de archivo */
fp = fopen(name, "r");
if (fp == NULL) return NULL;
fread(&tipo, sizeof(char), 1, fp);
}
tmp = (EMUFS *)malloc(sizeof(EMUFS));
- if (tmp == NULL) return NULL;
+ if (tmp == NULL) {
+ fclose(fp);
+ return NULL;
+ }
switch (tipo) {
case T1:
}
fclose(f_block_free);
+
+ /* Imprimo la lista de bloques/registros */
+ strcpy(name_f_block_free,emu->nombre);
+ strcat(name_f_block_free,".idx");
+ {
+ BLOCK_REG_T r;
+ f_block_free = fopen(name_f_block_free, "r");
+ fread(&r, sizeof(BLOCK_REG_T), 1, f_block_free);
+ while (!feof(f_block_free)) {
+ printf("ID %ld en bloque %d\n", r.id_reg, r.block);
+ fread(&r, sizeof(BLOCK_REG_T), 1, f_block_free);
+ }
+ fclose(f_block_free);
+ }
+
+
return 0;
}