From: Leandro Lucarella Date: Sun, 18 Apr 2004 02:08:43 +0000 (+0000) Subject: Se agrega emufs_fsc_get_num_blocks(). X-Git-Tag: svn_import_r684~401 X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/commitdiff_plain/e3c23f272a05815f86a30cd233ec93f13310828b?ds=inline Se agrega emufs_fsc_get_num_blocks(). --- diff --git a/emufs/fsc.c b/emufs/fsc.c index 465d19f..8d643a9 100644 --- a/emufs/fsc.c +++ b/emufs/fsc.c @@ -519,12 +519,12 @@ EMUFS_FREE emufs_fsc_get_media_fs(EMUFS *emu) else return 0; } -int emufs_fsc_get_cant_bloques_vacios(EMUFS *emu) +EMUFS_BLOCK_ID emufs_fsc_get_cant_bloques_vacios(EMUFS *emu) { FILE *f_fsc; EMUFS_FSC reg; char name_f_fsc[255]; - int cant=0; + EMUFS_BLOCK_ID cant=0; strcpy(name_f_fsc,emu->nombre); strcat(name_f_fsc, EMUFS_FSC_EXT); @@ -548,3 +548,22 @@ int emufs_fsc_truncate(EMUFS* efs, EMUFS_BLOCK_ID blocks) 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,emu->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; +} + diff --git a/emufs/fsc.h b/emufs/fsc.h index 8a228f9..b700a8d 100644 --- a/emufs/fsc.h +++ b/emufs/fsc.h @@ -97,9 +97,12 @@ EMUFS_FREE emufs_fsc_get_media_fs(EMUFS *emu); int emufs_fsc_get_max_min_fs(EMUFS *emu, EMUFS_FREE *min, EMUFS_FREE *max); /** Trunca el archivo hasta el bloque \param block*/ -int emufs_fsc_truncate(EMUFS *emu, EMUFS_BLOCK_ID block); +int emufs_fsc_truncate(EMUFS*, EMUFS_BLOCK_ID); /** Devuelve la cantidad de bloques vacios en el archivo*/ -int emufs_fsc_get_cant_bloques_vacios(EMUFS *emu); +EMUFS_BLOCK_ID emufs_fsc_get_cant_bloques_vacios(EMUFS*); + +/** Devuelve la cantidad de bloques (o gaps) que tiene un archivo. */ +EMUFS_BLOCK_ID emufs_fsc_get_num_blocks(EMUFS*); #endif /* _EMUFS_FSC_H */