rename (C)

From Wikipedia, the free encyclopedia

rename is a function in the C programming language that renames a certain file.

The prototype of the function is:

int rename(const char *oldname, const char *newname)

Zero is returned upon success, and other integers are returned upon failure.

The rename function is specified in the stdio.h library header file in C and the cstdio header in C++. It is specified in ANSI C.

In POSIX, rename will fail (with EXDEV) if the old and new names are on different mounted file systems.[1] On Linux, if a call to rename succeeds it is guaranteed to have been atomic from the point of view of the current host.

[edit] References

  1. ^ rename: rename a file – System Interfaces Reference, The Single UNIX® Specification, Issue 6 from The Open Group
Languages