C standard library
The C standard library provides a function called "rename" which does this action. In POSIX, which is extended from the C standard, the "rename" function will fail if the old and new names are on different mounted file systems.