1 /* vim: set noexpandtab tabstop=4 shiftwidth=4:
2 *----------------------------------------------------------------------------
4 *----------------------------------------------------------------------------
5 * This file is part of emufs.
7 * emufs is free software; you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option) any later
12 * emufs is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along
18 * with emufs; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
20 *----------------------------------------------------------------------------
21 * Creado: jue abr 8 18:07:57 ART 2004
22 * Autores: Nicolás Dimov <sagardua@uolsinectis.com.ar>
23 *----------------------------------------------------------------------------
31 * Manejo de archivos de índices de registros borrados (reutilizables).
33 * Implementación del manejo de archivos de índices de registros borrados
40 int emufs_did_get_last(EMUFS *emu)
46 strcpy(name_f_did, emu->nombre);
47 strcat(name_f_did, ".did");
49 if ( (f_did = fopen(name_f_did,"r")) == NULL) return -1; /*ERROR*/
50 fseek(f_did, 0, SEEK_END);
52 if (ftell(f_did) > 0){
53 /* si el archivo no esta vacio es porque hay un nro disponible*/
54 fseek(f_did, -sizeof(int),SEEK_END);
55 /* leo el ultimo numero */
56 fread(&id,sizeof(int),1,f_did);
58 fseek(f_did, 0, SEEK_END);
59 /* mido el tamaño del archivo*/
60 offset = ftell(f_did);
63 truncate(name_f_did, offset - sizeof(int));
66 /* si el archivo esta vacio */