+
+EMUFS_REG_ID emufs_idx_get_new_id(EMUFS* efs, int* err)
+{
+ EMUFS_REG_ID id;
+
+ id = emufs_did_get_last(efs, err);
+ if (id == EMUFS_NOT_FOUND) {
+ if (*err) {
+ PERR("error al obtener ultimo id");
+ return id;
+ }
+ id = emufs_idx_buscar_mayor_id_libre(efs, err);
+ if (*err) {
+ PERR("error al obtener id mayor");
+ return EMUFS_NOT_FOUND;
+ }
+ }
+ return id;
+}
+
+EMUFS_REG_ID emufs_idx_get_count(EMUFS *emu)
+{
+ FILE *fp;
+ char name_f_idx[255];
+ EMUFS_REG_ID tam;
+
+ strcpy(name_f_idx,emu->nombre);
+ strcat(name_f_idx, EMUFS_IDX_EXT);
+
+ fp = fopen(name_f_idx, "rb");
+ if (fp == NULL) return 0;
+
+ fseek(fp, 0l, SEEK_END);
+ tam = ftell(fp);
+ fclose(fp);
+
+ return tam/sizeof(EMUFS_IDX);
+}
+
+EMUFS_REG_ID emufs_idx_get_id_at(EMUFS *emu, long pos)
+{
+ FILE *fp;
+ char name_f_idx[255];
+ EMUFS_IDX id;
+
+ strcpy(name_f_idx,emu->nombre);
+ strcat(name_f_idx, EMUFS_IDX_EXT);
+
+ fp = fopen(name_f_idx, "rb");
+ if (fp == NULL) return EMUFS_NOT_FOUND;
+
+ fseek(fp, pos*sizeof(EMUFS_IDX), SEEK_SET);
+ fread(&id, sizeof(EMUFS_IDX), 1, fp);
+ fclose(fp);
+
+ return id.id_reg;
+}
+
+int emufs_idx_get_cant_reg(EMUFS* emu)
+{
+ FILE *fp;
+ char name_f_idx[255];
+ long cant;
+ strcpy(name_f_idx,emu->nombre);
+ strcat(name_f_idx, EMUFS_IDX_EXT);
+
+ if ( (fp = fopen(name_f_idx, "r")) == NULL ) return -1;/*EMUFS_NOT_FOUND*/;
+ fseek(fp, 0, SEEK_END);
+ cant = ftell(fp)/sizeof(EMUFS_IDX);
+ fclose(fp);
+ return cant;
+}