X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/e7e2badf7ebc4b6aeaf03366ad6fe6b919713d54..a73a4c8cb85f03d9863db77f85adb4db42a91286:/emufs/did.c?ds=inline diff --git a/emufs/did.c b/emufs/did.c index 0e3b79f..90a200b 100644 --- a/emufs/did.c +++ b/emufs/did.c @@ -1,4 +1,43 @@ +/* vim: set noexpandtab tabstop=4 shiftwidth=4: + *---------------------------------------------------------------------------- + * emufs + *---------------------------------------------------------------------------- + * This file is part of emufs. + * + * emufs is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * emufs is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along + * with emufs; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + *---------------------------------------------------------------------------- + * Creado: jue abr 8 18:07:57 ART 2004 + * Autores: Nicolás Dimov + *---------------------------------------------------------------------------- + * + * $Id$ + * + */ + +/** \file + * + * Manejo de archivos de índices de registros borrados (reutilizables). + * + * Implementación del manejo de archivos de índices de registros borrados + * (reutilizables). + * + */ + #include "did.h" +#include +#include int emufs_did_get_last(EMUFS *emu) { @@ -7,7 +46,7 @@ int emufs_did_get_last(EMUFS *emu) char name_f_did[255]; strcpy(name_f_did, emu->nombre); - strcat(name_f_did, ".did"); + strcat(name_f_did, EMUFS_DID_EXT); if ( (f_did = fopen(name_f_did,"r")) == NULL) return -1; /*ERROR*/ fseek(f_did, 0, SEEK_END); @@ -31,3 +70,19 @@ int emufs_did_get_last(EMUFS *emu) } return id; } + +/*agrego un elemento al archivo */ +int emufs_did_agregar(EMUFS *emu, int ID) +{ + FILE *f_did; + char name_f_did[255]; + + strcpy(name_f_did, emu->nombre); + strcat(name_f_did, EMUFS_DID_EXT); + + if ( (f_did = fopen(name_f_did,"a+")) == NULL) return -1; + fwrite(&ID, sizeof(int), 1, f_did); + fclose(f_did); + + return 0; +}