+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);
+
+ if ( (fp = fopen(name_f_idx, "rb"))==NULL){
+ PERR("No se pudo abrir el archvo");
+ return -1;
+ }
+
+ 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);
+
+ if ( (fp = fopen(name_f_idx, "rb")) == NULL){
+ PERR("No se pudo abrir el archivo");
+ return -1;
+ }
+
+ fseek(fp, pos*sizeof(EMUFS_IDX), SEEK_SET);
+ fread(&id, sizeof(EMUFS_IDX), 1, fp);
+ fclose(fp);
+
+ return id.id_reg;
+}
+
+int emufs_idx_existe_id(EMUFS *emu, int ID)
+{
+ FILE *fp;
+ char name_f_idx[255];
+ EMUFS_IDX id;
+
+ strcpy(name_f_idx,emu->nombre);
+ strcat(name_f_idx, EMUFS_IDX_EXT);
+
+ if ( (fp = fopen(name_f_idx, "rb")) == NULL){
+ PERR("No se pudo abrir el archivo");
+ return -1;
+ }
+
+ while ( !feof(fp) ){
+ fread(&id, sizeof(EMUFS_IDX), 1, fp);
+ if ( id.id_reg == ID ){
+ fclose(fp);
+ return 0;
+ }
+ }
+ fclose(fp);
+ return -1;
+}