*/
#include "did.h"
+#include <string.h>
+#include <unistd.h>
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);
}
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;
+}