strcpy(name_f_idx, emu->nombre);
strcat(name_f_idx, EMUFS_IDX_EXT);
- (*err) = 0;
if ((f_idx = fopen(name_f_idx, "rb")) == NULL) {
PERR("No se puede abrir archivo");
*err = 4; /* EMUFS_ERROR_CANT_OPEN_FILE */
{
EMUFS_REG_ID id;
- (*err) = 0;
id = emufs_did_get_last(efs, err);
if (id == EMUFS_NOT_FOUND) {
+ if (*err) {
+ PERR("error al obtener ultimo id");
+ return id;
+ }
id = emufs_idx_buscar_mayor_id_libre(efs, err);
if (*err) {
PERR("error al obtener id mayor");
return id;
}
-unsigned int emufs_idx_get_count(EMUFS *emu)
+EMUFS_REG_ID emufs_idx_get_count(EMUFS *emu)
{
FILE *fp;
char name_f_idx[255];
- long tam;
+ EMUFS_REG_ID tam;
strcpy(name_f_idx,emu->nombre);
strcat(name_f_idx, EMUFS_IDX_EXT);
- fp = fopen(name_f_idx, "r");
+ fp = fopen(name_f_idx, "rb");
if (fp == NULL) return 0;
- fseek(fp, 0, SEEK_END);
+ fseek(fp, 0l, SEEK_END);
tam = ftell(fp);
fclose(fp);
return tam/sizeof(EMUFS_IDX);
}
-unsigned long emufs_idx_get_id_att(EMUFS *emu, unsigned int pos)
+EMUFS_REG_ID emufs_idx_get_id_at(EMUFS *emu, long pos)
{
FILE *fp;
char name_f_idx[255];
strcpy(name_f_idx,emu->nombre);
strcat(name_f_idx, EMUFS_IDX_EXT);
- fp = fopen(name_f_idx, "r");
+ fp = fopen(name_f_idx, "rb");
if (fp == NULL) return EMUFS_NOT_FOUND;
fseek(fp, pos*sizeof(EMUFS_IDX), SEEK_SET);
return id.id_reg;
}
-