X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/e52a96783c670a27aa0b5613f2771dd39a9f74e1..d3112f9c7895a9f419c365eabe7db963e148454a:/tipo3/emufs.c diff --git a/tipo3/emufs.c b/tipo3/emufs.c index 9883f70..a769741 100644 --- a/tipo3/emufs.c +++ b/tipo3/emufs.c @@ -81,6 +81,44 @@ EMUFS *emufs_crear(const char *filename, char tipo, unsigned int tam_bloque, uns return tmp; } +EMUFS *emufs_abrir(const char *filename) +{ + EMUFS *tmp; + char name[255]; + char tipo; + FILE *fp; + + strcpy(name, filename); + strcat(name, EXT_TIPO3_DATA); + fp = fopen(name, "r"); + if (fp == NULL) return NULL; + fread(&tipo, sizeof(char), 1, fp); + if ((tipo < 0) || (tipo > 2)) { + fclose(fp); + return NULL; + } + + tmp = (EMUFS *)malloc(sizeof(EMUFS)); + if (tmp == NULL) return NULL; + + switch (tipo) { + case T1: + break; + case T2: + break; + case T3: + tmp->tipo = tipo; + fread(&tmp->tam_bloque, sizeof(int), 1, fp); + tmp->leer_bloque = leer_bloque; + tmp->leer_registro = leer_registro; + tmp->grabar_registro = grabar_registro; + tmp->borrar_registro = NULL; + tmp->nombre = str_dup(filename); + } + + fclose(fp); + return tmp; +} int emufs_destruir(EMUFS *e) {