+
+EMUFS_FREE emufs_fsc_get_media_fs(EMUFS *emu)
+{
+ FILE *f_fsc;
+ EMUFS_FSC reg;
+ char name_f_fsc[255];
+ EMUFS_FREE total_fs = 0;
+ EMUFS_REG_ID gap_count = 0;
+
+ strcpy(name_f_fsc,emu->nombre);
+ strcat(name_f_fsc, EMUFS_FSC_EXT);
+
+ if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return -1;
+
+ while ( !feof(f_fsc) ){
+ if ( fread(®, sizeof(EMUFS_FSC), 1, f_fsc) != 1) continue;
+ total_fs += reg.freespace;
+ ++gap_count;
+ }
+
+ fclose(f_fsc);
+
+ if (gap_count > 0) return total_fs/gap_count;
+ else return 0;
+}
+
+EMUFS_BLOCK_ID emufs_fsc_get_cant_bloques_vacios(EMUFS *emu)
+{
+ FILE *f_fsc;
+ EMUFS_FSC reg;
+ char name_f_fsc[255];
+ EMUFS_BLOCK_ID cant=0;
+
+ strcpy(name_f_fsc,emu->nombre);
+ strcat(name_f_fsc, EMUFS_FSC_EXT);
+
+ if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return -1;
+ while ( !feof(f_fsc) ){
+ fread(®, sizeof(EMUFS_FSC), 1, f_fsc);
+ if ( reg.freespace == emu->tam_bloque )
+ cant++;
+ }
+
+ fclose(f_fsc);
+ return cant;
+}
+
+int emufs_fsc_truncate(EMUFS* efs, EMUFS_BLOCK_ID blocks)
+{
+ char name_f_fsc[255];
+
+ strcpy(name_f_fsc, efs->nombre);
+ strcat(name_f_fsc, EMUFS_FSC_EXT);
+ return truncate(name_f_fsc, blocks * sizeof(EMUFS_FSC));
+}
+
+EMUFS_BLOCK_ID emufs_fsc_get_num_blocks(EMUFS* efs)
+{
+ FILE *f_fsc;
+ char name_f_fsc[255];
+ EMUFS_BLOCK_ID cant = 0;
+
+ strcpy(name_f_fsc, efs->nombre);
+ strcat(name_f_fsc, EMUFS_FSC_EXT);
+
+ if (!(f_fsc = fopen(name_f_fsc, "ab"))) {
+ PERR("error al abrir archivo .fsc");
+ return EMUFS_NOT_FOUND;
+ }
+ cant = ftell(f_fsc) / sizeof(EMUFS_FSC);
+ fclose(f_fsc);
+ return cant;
+}
+
+long emufs_fsc_get_file_size(EMUFS* efs, int* err)
+{
+ char name[255];
+ strcpy(name, efs->nombre);
+ strcat(name, EMUFS_FSC_EXT);
+ return emufs_common_get_file_size(name, err);
+}
+