\r
<div class="para func">\r
<h2>f_rename</h2>\r
-<p>Renames a file or sub-directory.</p>\r
+<p>The f_rename function renames and/or moves a file or sub-directory.</p>\r
<pre>\r
FRESULT f_rename (\r
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] Old object name */</span>\r
<h4>Parameters</h4>\r
<dl class="par">\r
<dt>old_name</dt>\r
-<dd>Pointer to a null-terminated string that specifies an existing <a href="filename.html">file or sub-directory</a> to be renamed.</dd>\r
+<dd>Pointer to a null-terminated string that specifies the existing <a href="filename.html">file or sub-directory</a> to be renamed.</dd>\r
<dt>new_name</dt>\r
-<dd>Pointer to a null-terminated string that specifies the new object name. The drive number specified in this string is ignored and one determined by <tt class="arg">old_name</tt> is used instead.</dd>\r
+<dd>Pointer to a null-terminated string that specifies the new object name. A drive number may be specified in this string but it is ignored and assumed as the same drive of the <tt class="arg">old_name</tt>. Any object with this path name except <tt class="arg">old_name</tt> must not be exist, or the function fails with <tt>FR_EXIST</tt>.</dd>\r
</dl>\r
</div>\r
\r
\r
<div class="para desc">\r
<h4>Description</h4>\r
-<p>Renames a file or sub-directory and can also move it to other directory within the same logical drive. <em>Do not rename open objects</em> or directry table can be broken.</p>\r
+<p>Renames a file or sub-directory and can also move it to other directory in the same volume. The object to be renamed must not be an open object, or <em>the FAT volume can be collapsed</em>. Such the wrong operation is rejected safely when <a href="appnote.html#dup">file lock function</a> is enabled.</p>\r
</div>\r
\r
\r
<div class="para use">\r
<h4>Example</h4>\r
<pre>\r
- <span class="c">/* Rename an object */</span>\r
+ <span class="c">/* Rename an object in the default drive */</span>\r
f_rename("oldname.txt", "newname.txt");\r
\r
- <span class="c">/* Rename and move an object to other directory */</span>\r
- f_rename("oldname.txt", "dir1/newname.txt");\r
+ <span class="c">/* Rename an object in the drive 2 */</span>\r
+ f_rename("2:oldname.txt", "newname.txt");\r
+\r
+ <span class="c">/* Rename an object and move it to other directory in the volume */</span>\r
+ f_rename("log.txt", "old/log0001.txt");\r
</pre>\r
</div>\r
\r