#include "fsc.h"
#include "error.h"
+#include "common.h"
#include <unistd.h>
-#include <sys/types.h>
#include <string.h>
/* Crea un archivo de Gaps o Espacio Libre en Bloque */
/* Busco el gap que sucede a este */
fseek(f_fsc,0,SEEK_SET);
while (!feof(f_fsc)) {
- fread(&gap_aux,sizeof(EMUFS_FSC),1,f_fsc);
+ if (fread(&gap_aux,sizeof(EMUFS_FSC),1,f_fsc) != 1) continue;
if (gap_aux.marker > gap_new.marker) {
found = 1;
break;
/** Busca n lugares consecutivos devolviendo el id del primer bloque. */
EMUFS_BLOCK_ID emufs_fsc_buscar_n_lugares(EMUFS* efs, size_t n,
- EMUFS_FREE reg_size, EMUFS_FREE *freespace, int* err)
+ EMUFS_FREE size, EMUFS_FREE *freespace, int* err)
{
FILE *f_fsc;
EMUFS_FSC reg;
*err = EMUFS_ERROR_FILE_READ;
return EMUFS_NOT_FOUND;
}
- if (reg.freespace >= reg_size) {
+ if (reg.freespace >= size) {
int found = 1;
EMUFS_BLOCK_ID first_id = reg.marker;
*freespace = reg.freespace;
return EMUFS_NOT_FOUND;
}
/* no hay otro lugar consecutivo */
- if (reg.freespace < reg_size) {
+ if (reg.freespace < size) {
found = 0;
break;
}
total = 0;
while ( !feof(f_fsc) ){
if ( fread(®, sizeof(EMUFS_FSC), 1, f_fsc) != 1) continue;
- total += reg.freespace;
+ if ( reg.freespace > 0 )
+ total += reg.freespace;
}
fclose(f_fsc);
return total;
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);
+}