提交 3d21a838 编写于 作者: B bernard.xiong@gmail.com

fixed rename issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1798 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 8b091fc7
......@@ -11,6 +11,7 @@
* Date Author Notes
* 2008-02-22 QiuYi The first version.
* 2011-10-08 Bernard fixed the block size in statfs.
* 2011-11-23 Bernard fixed the rename issue.
*/
#include <rtthread.h>
......@@ -535,7 +536,8 @@ int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* n
FRESULT result;
#if _VOLUMES > 1
char *drivers_oldfn, *drivers_newfn;
char *drivers_oldfn;
const char *drivers_newfn;
int vol;
extern int elm_get_vol(FATFS *fat);
......@@ -545,15 +547,9 @@ int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* n
drivers_oldfn = rt_malloc(256);
if (drivers_oldfn == RT_NULL) return -DFS_STATUS_ENOMEM;
drivers_newfn = rt_malloc(256);
if (drivers_newfn == RT_NULL)
{
rt_free(drivers_oldfn);
return -DFS_STATUS_ENOMEM;
}
drivers_newfn = newpath;
rt_snprintf(drivers_oldfn, 256, "%d:%s", vol, oldpath);
rt_snprintf(drivers_newfn, 256, "%d:%s", vol, newpath);
#else
const char *drivers_oldfn, *drivers_newfn;
......@@ -564,7 +560,6 @@ int dfs_elm_rename(struct dfs_filesystem* fs, const char* oldpath, const char* n
result = f_rename(drivers_oldfn, drivers_newfn);
#if _VOLUMES > 1
rt_free(drivers_oldfn);
rt_free(drivers_newfn);
#endif
return elm_result_to_dfs(result);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册