a94c79bebf0ccf504aa94541f7bfffbdb90fcb2a kent Tue Apr 9 18:47:15 2013 -0700 Adding mustRename wrapper around rename(). diff --git src/lib/osunix.c src/lib/osunix.c index 9b5b71b..b44692d 100644 --- src/lib/osunix.c +++ src/lib/osunix.c @@ -338,30 +338,38 @@ char *x; static char fileName[PATH_LEN]; int i; char *lastSlash = (lastChar(dir) == '/' ? "" : "/"); for (i=0;;++i) { x = semiUniqName(base); safef(fileName, sizeof(fileName), "%s%s%s%d%s", dir, lastSlash, x, i, suffix); if (!fileExists(fileName)) break; } return fileName; } +void mustRename(char *oldName, char *newName) +/* Rename file or die trying. */ +{ +int err = rename(oldName, newName); +if (err < 0) + errnoAbort("Couldn't rename %s to %s", oldName, newName); +} + static void eatSlashSlashInPath(char *path) /* Convert multiple // to single // */ { char *s, *d; s = d = path; char c, lastC = 0; while ((c = *s++) != 0) { if (c == '/' && lastC == c) continue; *d++ = c; lastC = c; } *d = 0; }