blob: 22e9a7b9c88e172fee96fcc3b1f7138d6dabb76c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
* $Id: removeFile.c,v 1.4 2000/04/06 10:33:07 rrt Exp $
*
* removeFile Runtime Support
*/
#include "Rts.h"
#include "stgio.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
StgInt
removeFile(StgByteArray path)
{
struct stat sb;
/* Check for a non-directory */
while (stat(path, &sb) != 0) {
if (errno != EINTR) {
cvtErrno();
stdErrno();
return -1;
}
}
if (S_ISDIR(sb.st_mode)) {
ghc_errtype = ERR_INAPPROPRIATETYPE;
ghc_errstr = "file is a directory";
return -1;
}
while (unlink(path) != 0) {
if (errno != EINTR) {
cvtErrno();
stdErrno();
return -1;
}
}
return 0;
}
|