-
- while ( !feof(f_fsc) ){
- fread(®, sizeof(EMUFS_FSC), 1, f_fsc);
- if ( reg.freespace < *min )
- *min = reg.freespace;
- if ( reg.freespace > *max )
- *max = reg.freespace;
+
+ /* Si el file esta vacio, devuelvo valores nulos */
+ fseek(f_fsc,0,SEEK_END);
+ if (ftell(f_fsc) == 0) {
+ *min = 0;
+ *max = 0;
+ return 0;
+ }
+ else
+ {
+ /* Busco Min y Max */
+ *min = ULONG_MAX;
+ *max = 0;
+ fseek(f_fsc,0,SEEK_SET);
+ while ( !feof(f_fsc) ){
+ if ( fread(®, sizeof(EMUFS_FSC), 1, f_fsc) != 1) continue;
+ if ( reg.freespace < *min )
+ *min = reg.freespace;
+ if ( reg.freespace > *max )
+ *max = reg.freespace;
+ }
+ fclose(f_fsc);
+ return 0;