forked from len0rd/rockbox
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
This commit is contained in:
parent
1a6a4812aa
commit
e0e0140f4e
3 changed files with 44 additions and 12 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue