[fs.op.rename]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.op.rename)

### 31.12.13 Filesystem operation functions [[fs.op.funcs]](fs.op.funcs#fs.op.rename)

#### 31.12.13.33 Rename [fs.op.rename]

[ð](#lib:rename)

`void filesystem::rename(const path& old_p, const path& new_p);
void filesystem::rename(const path& old_p, const path& new_p, error_code& ec) noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18508)

*Effects*: Renames old_p to new_p, as if by
 POSIX rename[.](#1.sentence-1)

[*Note [1](#note-1)*: 

- [(1.1)](#1.1)

  If old_p and new_p resolve to the same existing file,
 no action is taken[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Otherwise, the rename can include the following effects:
  * [(1.2.1)](#1.2.1)

if new_p resolves to an existing non-directory file, new_p is removed; otherwise,

  * [(1.2.2)](#1.2.2)

if new_p resolves to an existing directory, new_p is removed if empty on POSIX compliant operating systems
 but might be an error on other operating systems[.](#1.2.sentence-1)

A symbolic link is itself renamed, rather than the file it resolves to[.](#1.sentence-2)

â *end note*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18529)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#2.sentence-1)
