summaryrefslogtreecommitdiff
path: root/ext/dbase
diff options
context:
space:
mode:
authorVlad Krupin <vlad@php.net>2001-12-31 12:52:34 +0000
committerVlad Krupin <vlad@php.net>2001-12-31 12:52:34 +0000
commit543077d9153900fc13b00829bba7e345459175f0 (patch)
treeea5c18187d2643fad072455702fddb38d7add400 /ext/dbase
parent2f0cd79621ffc21f9fd1aa50d6eb497a1f59b879 (diff)
downloadphp-git-543077d9153900fc13b00829bba7e345459175f0.tar.gz
Now dbase_pack() actually truncates the resulting .dbf file to the right
size (possibly fixing bug #6852 #3). @Make dbase_pack() truncate the file to the right size. (Vlad)
Diffstat (limited to 'ext/dbase')
-rw-r--r--ext/dbase/dbf_rec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/dbase/dbf_rec.c b/ext/dbase/dbf_rec.c
index 44d90b69d2..11ee63b107 100644
--- a/ext/dbase/dbf_rec.c
+++ b/ext/dbase/dbf_rec.c
@@ -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;
}