From e0e0140f4e63b451a110840dc5ef5c22c3ed9f7c Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sun, 22 Aug 2004 11:28:24 +0000 Subject: Bug fix: renaming a directory could cause a name clash. New feature: rename() can now move files/directories as well. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5008 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 1b530153a5..e41bbaca41 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1551,12 +1551,13 @@ int fat_remove(struct fat_file* file) } int fat_rename(struct fat_file* file, - const unsigned char* newname, - int size, - int attr) + struct fat_dir* dir, + const unsigned char* newname, + int size, + int attr) { int rc; - struct fat_dir dir; + struct fat_dir olddir; struct fat_file newfile = *file; if ( !file->dircluster ) { @@ -1565,12 +1566,12 @@ int fat_rename(struct fat_file* file, } /* create a temporary file handle */ - rc = fat_opendir(&dir, file->dircluster, NULL); + rc = fat_opendir(&olddir, file->dircluster, NULL); if (rc < 0) return rc * 10 - 2; /* create new name */ - rc = add_dir_entry(&dir, &newfile, newname, false, false); + rc = add_dir_entry(dir, &newfile, newname, false, false); if (rc < 0) return rc * 10 - 3; -- cgit v1.2.3