20 lines
268 B
C
20 lines
268 B
C
|
#include <stdio.h>
|
||
|
#include <unistd.h>
|
||
|
#include <sys/stat.h>
|
||
|
|
||
|
int remove(char const *filename)
|
||
|
{
|
||
|
struct stat st;
|
||
|
|
||
|
int rc = stat(filename, &st);
|
||
|
if(rc < 0)
|
||
|
return -1;
|
||
|
|
||
|
if(S_ISDIR(st.st_mode)) {
|
||
|
return rmdir(filename);
|
||
|
}
|
||
|
else {
|
||
|
return unlink(filename);
|
||
|
}
|
||
|
}
|