summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-08-22 11:28:24 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-08-22 11:28:24 +0000
commite0e0140f4e63b451a110840dc5ef5c22c3ed9f7c (patch)
tree6e48d6ddc4609f9a49eb2913b145b8d1f81e5436 /firmware/drivers
parent1a6a4812aa46d66ca46e308897e0cf759e42773f (diff)
downloadrockbox-e0e0140f4e63b451a110840dc5ef5c22c3ed9f7c.tar.gz
rockbox-e0e0140f4e63b451a110840dc5ef5c22c3ed9f7c.zip
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
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/fat.c13
1 files changed, 7 insertions, 6 deletions
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)
1551} 1551}
1552 1552
1553int fat_rename(struct fat_file* file, 1553int fat_rename(struct fat_file* file,
1554 const unsigned char* newname, 1554 struct fat_dir* dir,
1555 int size, 1555 const unsigned char* newname,
1556 int attr) 1556 int size,
1557 int attr)
1557{ 1558{
1558 int rc; 1559 int rc;
1559 struct fat_dir dir; 1560 struct fat_dir olddir;
1560 struct fat_file newfile = *file; 1561 struct fat_file newfile = *file;
1561 1562
1562 if ( !file->dircluster ) { 1563 if ( !file->dircluster ) {
@@ -1565,12 +1566,12 @@ int fat_rename(struct fat_file* file,
1565 } 1566 }
1566 1567
1567 /* create a temporary file handle */ 1568 /* create a temporary file handle */
1568 rc = fat_opendir(&dir, file->dircluster, NULL); 1569 rc = fat_opendir(&olddir, file->dircluster, NULL);
1569 if (rc < 0) 1570 if (rc < 0)
1570 return rc * 10 - 2; 1571 return rc * 10 - 2;
1571 1572
1572 /* create new name */ 1573 /* create new name */
1573 rc = add_dir_entry(&dir, &newfile, newname, false, false); 1574 rc = add_dir_entry(dir, &newfile, newname, false, false);
1574 if (rc < 0) 1575 if (rc < 0)
1575 return rc * 10 - 3; 1576 return rc * 10 - 3;
1576 1577