resetting manifest requested domain to floor
[platform/upstream/ccache.git] / test / util.c
1 /*
2  * Copyright (C) 2010 Joel Rosdahl
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 3 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #include "system.h"
20 #include "test/util.h"
21
22 bool
23 path_exists(const char *path)
24 {
25         struct stat st;
26         return lstat(path, &st) == 0;
27 }
28
29 bool
30 is_symlink(const char *path)
31 {
32         struct stat st;
33         return lstat(path, &st) == 0 && S_ISLNK(st.st_mode);
34 }
35
36 void
37 create_file(const char *path, const char *content)
38 {
39         FILE *f = fopen(path, "w");
40         if (!f || fputs(content, f) < 0) {
41                 fprintf(stderr, "create_file: %s: %s\n", path, strerror(errno));
42         }
43         if (f) {
44                 fclose(f);
45         }
46 }