add DFS_FS_FLAG_FULLPATH support in rename function.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1905 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
beaf51ff82
commit
fcf74ed108
|
@ -420,6 +420,7 @@ int dfs_file_rename(const char *oldpath, const char *newpath)
|
||||||
|
|
||||||
result = DFS_STATUS_OK;
|
result = DFS_STATUS_OK;
|
||||||
newfullpath = RT_NULL;
|
newfullpath = RT_NULL;
|
||||||
|
oldfullpath = RT_NULL;
|
||||||
|
|
||||||
oldfullpath = dfs_normalize_path(RT_NULL, oldpath);
|
oldfullpath = dfs_normalize_path(RT_NULL, oldpath);
|
||||||
if (oldfullpath == RT_NULL)
|
if (oldfullpath == RT_NULL)
|
||||||
|
@ -435,33 +436,29 @@ int dfs_file_rename(const char *oldpath, const char *newpath)
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oldfs = dfs_filesystem_lookup(oldfullpath)) == RT_NULL)
|
oldfs = dfs_filesystem_lookup(oldfullpath);
|
||||||
{
|
newfs = dfs_filesystem_lookup(newfullpath);
|
||||||
result = -DFS_STATUS_ENOENT;
|
|
||||||
goto __exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((newfs = dfs_filesystem_lookup(newfullpath)) == RT_NULL)
|
|
||||||
{
|
|
||||||
result = -DFS_STATUS_ENOENT;
|
|
||||||
goto __exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldfs == newfs)
|
if (oldfs == newfs)
|
||||||
{
|
{
|
||||||
if (oldfs->ops->rename == RT_NULL)
|
if (oldfs->ops->rename == RT_NULL)
|
||||||
{
|
{
|
||||||
result = -DFS_STATUS_ENOSYS;
|
result = -DFS_STATUS_ENOSYS;
|
||||||
goto __exit;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* use sub directory to rename in file system */
|
{
|
||||||
result = oldfs->ops->rename(oldfs, dfs_subdir(oldfs->path, oldfullpath),
|
if (oldfs->ops->flags & DFS_FS_FLAG_FULLPATH)
|
||||||
dfs_subdir(newfs->path, newfullpath));
|
result = oldfs->ops->rename(oldfs, oldfullpath, newfullpath);
|
||||||
goto __exit;
|
else
|
||||||
|
/* use sub directory to rename in file system */
|
||||||
|
result = oldfs->ops->rename(oldfs, dfs_subdir(oldfs->path, oldfullpath),
|
||||||
|
dfs_subdir(newfs->path, newfullpath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = -DFS_STATUS_EXDEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = -DFS_STATUS_EXDEV;
|
|
||||||
|
|
||||||
__exit:
|
__exit:
|
||||||
rt_free(oldfullpath);
|
rt_free(oldfullpath);
|
||||||
|
|
Loading…
Reference in New Issue