+/* Elimina un registro GAP del archivo de espacios libres (gaps) */
+int emufs_fsc_remove_gap(EMUFS *emu, EMUFS_OFFSET n_marker)
+{
+ FILE *f_fsc;
+ EMUFS_FSC gap_aux;
+ char name_f_fsc[255];
+ unsigned long n_source,n_destination,n_filesize,n_reg_count = 0,n_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.n_marker == n_marker ) break;
+ }
+
+ /* Preparo el escenario para la movida de registros */
+ fseek(f_fsc,-sizeof(EMUFS_FSC),SEEK_CUR);
+ n_destination = ftell(f_fsc);
+ n_source = n_destination+sizeof(EMUFS_FSC); /* Salteo el gap a eliminar! */
+ fseek(f_fsc,0,SEEK_END);
+ n_filesize = ftell(f_fsc);
+ n_reg_count = (n_filesize - n_source) / sizeof(EMUFS_FSC);
+ printf("Destination: %lu Source: %lu Cant Regs a Mover: %lu\n",n_destination,n_source,n_reg_count);
+
+ /* Comienzo a mover */
+ while (n_moved < n_reg_count) {
+ fseek(f_fsc,n_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);
+ n_source += sizeof(EMUFS_FSC);
+ ++n_moved;
+ }
+ fclose(f_fsc);
+ truncate(name_f_fsc, n_filesize - sizeof(EMUFS_FSC));
+
+ return 0;
+}
+