2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: renameFile.c,v 1.6 2000/04/05 17:05:50 rrt Exp $
6 * renameFile Runtime Support
12 #ifdef HAVE_SYS_TYPES_H
13 #include <sys/types.h>
16 #ifdef HAVE_SYS_STAT_H
26 renameFile(opath, npath)
32 /* Check for a non-directory source */
33 while (stat(opath, &sb) != 0) {
40 if (S_ISDIR(sb.st_mode)) {
41 ghc_errtype = ERR_INAPPROPRIATETYPE;
42 ghc_errstr = "file is a directory";
46 /* Check for a non-directory destination */
47 while (stat(npath, &sb) != 0 && errno != ENOENT) {
55 if (errno != ENOENT) {
56 if (S_ISDIR(sb.st_mode)) {
57 ghc_errtype = ERR_INAPPROPRIATETYPE;
58 ghc_errstr = "file is a directory";
61 while (chmod(npath, S_IWRITE) != 0) {
68 while (unlink(npath) != 0) {
77 while(rename(opath, npath) != 0) {