]> granicus.if.org Git - php/commitdiff
Now dbase_pack() actually truncates the resulting .dbf file to the right
authorVlad Krupin <vlad@php.net>
Mon, 31 Dec 2001 12:52:34 +0000 (12:52 +0000)
committerVlad Krupin <vlad@php.net>
Mon, 31 Dec 2001 12:52:34 +0000 (12:52 +0000)
size (possibly fixing bug #6852 #3).
@Make dbase_pack() truncate the file to the right size. (Vlad)

ext/dbase/dbf_rec.c

index 44d90b69d2c3e86a4b8aa0952f30bec61c0235a2..11ee63b1072005fb67f29c008f8f3523f5efbf1c 100644 (file)
@@ -125,6 +125,12 @@ void pack_dbf(dbhead_t *dbh)
                rec_cnt--;
        }
        free(cp);
+
+       /* Try to truncate the file to the right size. */
+       if (ftruncate(dbh->db_fd, out_off) != 0) {
+           php_error(E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there.");
+       }
+
        if (rec_cnt == 0)
                dbh->db_records = new_cnt;
 }