+/* Elimina un registro GAP del archivo de espacios libres (gaps) */
+int emufs_fsc_remove_gap(EMUFS *emu, EMUFS_OFFSET marker)
+{
+ FILE *f_fsc;
+ EMUFS_FSC gap_aux;
+ char name_f_fsc[255];
+ unsigned long source,destination,file_size,reg_count = 0,cant_moved = 0;
+
+ strcpy(name_f_fsc,emu->nombre);
+ strcat(name_f_fsc, EMUFS_FSC_EXT);
+
+ /* Busco el Gap en el .fsc */
+ if ((f_fsc = fopen(name_f_fsc,"r+")) == NULL) return -1;
+ while ( !feof(f_fsc) ){
+ if ( fread(&gap_aux,sizeof(EMUFS_FSC),1,f_fsc) != 1) continue;
+ if ( gap_aux.marker == marker ) break;
+ }
+
+ /* Preparo el escenario para la movida de registros */
+ fseek(f_fsc,-sizeof(EMUFS_FSC),SEEK_CUR);
+ destination = ftell(f_fsc);
+ source = destination+sizeof(EMUFS_FSC); /* Salteo el gap a eliminar! */
+ fseek(f_fsc,0,SEEK_END);
+ file_size = ftell(f_fsc);
+ reg_count = (file_size - source) / sizeof(EMUFS_FSC);
+
+ /* Comienzo a mover */
+ while (cant_moved < reg_count) {
+ fseek(f_fsc,source,0);
+ fread(&gap_aux,sizeof(EMUFS_FSC),1,f_fsc);
+ fseek(f_fsc,-sizeof(EMUFS_FSC)*2,SEEK_CUR);
+ fwrite(&gap_aux,sizeof(EMUFS_FSC),1,f_fsc);
+ source += sizeof(EMUFS_FSC);
+ ++cant_moved;
+ }
+ fclose(f_fsc);
+ truncate(name_f_fsc, file_size - sizeof(EMUFS_FSC));
+
+ return 0;
+}
+