From 68640edf90c84c3d4494f0852f6236e1929a4603 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Mon, 11 Nov 2002 14:40:18 +0000 Subject: Added ftruncate(). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2827 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'firmware/drivers/fat.c') diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 74bdbd3491..ad1a7a0c82 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1002,12 +1002,15 @@ int fat_truncate(struct fat_file *file) { /* truncate trailing clusters */ int next; - int last = get_next_cluster(file->lastcluster); - while ( last && last != FAT_EOF_MARK ) { + int last = file->lastcluster; + + LDEBUGF("fat_truncate(%x, %x)\n", file->firstcluster, last); + + for ( last = get_next_cluster(last); last; last = next ) { next = get_next_cluster(last); update_fat_entry(last,0); - last = next; } + update_fat_entry(file->lastcluster,FAT_EOF_MARK); return 0; } -- cgit v1.2.3