summaryrefslogtreecommitdiff
path: root/src/stdio/remove.c
blob: e52132de310d1699b0b0bb9e159a69a6450783bb (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
#include <stdio.h>
#include "_stdio.h"
#include "_forced/stat.h"
#include "_forced/rmdir.h"
#include "_forced/unlink.h"

/** delete a file **/

int remove(const char *filename)
{
	struct stat st;

	SIGNAL_SAFE(0);

	stat(filename, &st);
	if (S_ISDIR(st.st_mode)) {
		return rmdir(filename);
	}
	return unlink(filename);
}

/***
function removes the file ARGUMENT(filename) so the future attempts to
open that file will fail unless creating a new file.
***/

/*
IMPLEMENTATION(Whether the file is removed if it is open)
STDC(1)
*/