1/*
2 * Copyright (c) 2011, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#include <stdio.h>
11#include <unistd.h>
12#include <errno.h>
13
14int remove(const char *filename)
15{
16    int ret;
17
18    // Try unlink first
19    ret = unlink(filename);
20
21    // If it was a directory, try rmdir() next
22    if(ret == -1 && errno == EPERM) {
23        return rmdir(filename);
24    }
25
26    return ret;
27}
28