From eab099a18ebaf8397f54955c8e740037bcee2f56 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 9 Apr 2004 20:14:28 +0000 Subject: [PATCH] Agrego emufs_idx_abrir() para abrir mas facil un archivo de indices (compila pero no probado). --- emufs/idx.c | 20 ++++++++++++++++++++ emufs/idx.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/emufs/idx.c b/emufs/idx.c index 9979070..be142f7 100644 --- a/emufs/idx.c +++ b/emufs/idx.c @@ -35,6 +35,26 @@ */ #include "idx.h" +#include +#include + +FILE* emufs_idx_abrir(EMUFS* efs, const char* mode) +{ + FILE* f; + char* filename; + + filename = (char*) malloc(sizeof(char) * (strlen(efs->nombre) + + strlen(EMUFS_IDX_EXT) + 1)); + if (filename == NULL) { + /* TODO Manejo de errores */ + return NULL; + } + strcpy(filename, efs->nombre); + strcat(filename, EMUFS_IDX_EXT); + f = fopen(filename, mode); + free(filename); + return f; +} int emufs_idx_buscar_mayor_id(EMUFS *emu) { diff --git a/emufs/idx.h b/emufs/idx.h index ca509c7..cb67b69 100644 --- a/emufs/idx.h +++ b/emufs/idx.h @@ -47,6 +47,8 @@ typedef struct emufs_idx_t { long int id_reg; } EMUFS_IDX; +FILE* emufs_idx_abrir(EMUFS*, const char*); + int emufs_idx_buscar_mayor_id(EMUFS *); int emufs_idx_buscar_registro(EMUFS *, int); -- 2.43.0