Prev, Top Notes, Next

Using the Library
Interface Sugar

if (rename(old_path, new_path) < 0)
{
    char buf[300];
    strerror_r(errno, buf, sizeof(buf));
    fprintf(stderr, "rename %s %s: %s\n",
        buf);
    exit(1);
}
 
explain_rename_or_die(old_path, new_path);
if (rename(old_path, new_path) < 0)
{
    char buf[300];
    strerror_r(errno, buf, sizeof(buf));
    fprintf(stderr, "rename %s %s: %s\n",
        buf);
    ...error recovery...
}
 
if (explain_rename_on_error(old_path, new_path) < 0)
{
    ...error recovery...
}