ERASEABLE
void db_save(int db, string filename)
{
+ string lock_filename = strcat(filename, ".lock");
+ int fh_lock = fopen(lock_filename, FILE_WRITE);
+ fputs(fh_lock, "LOCKED\n");
+ fclose(fh_lock);
+
int fh = fopen(filename, FILE_WRITE);
if (fh < 0)
{
for (int i = 0, n = buf_getsize(db); i < n; ++i)
fputs(fh, strcat(bufstr_get(db, i), "\n"));
fclose(fh);
+ fh_lock = fopen(lock_filename, FILE_WRITE);
+ fputs(fh_lock, "UNLOCKED\n");
+ fclose(fh_lock);
}
USING(HashMap, int);