chiark / gitweb /
Imported Debian patch 1.0.0-5
[e16] / src / file.h
1 /*
2  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3  * Copyright (C) 2007 Kim Woelders
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to
7  * deal in the Software without restriction, including without limitation the
8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9  * sell copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies of the Software, its documentation and marketing & publicity
14  * materials, and acknowledgment shall be given in the documentation, materials
15  * and software packages that this Software was used.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _FILE_H_
25 #define _FILE_H_
26
27 #include <time.h>
28
29 void                E_md(const char *s);
30 void                E_mv(const char *s, const char *ss);
31 void                E_rm(const char *s);
32 char              **E_ls(const char *dir, int *num);
33
34 #define EFILE_ANY   0x01
35 #define EFILE_REG   0x02
36 #define EFILE_DIR   0x04
37
38 #define EPERM_R     0x10
39 #define EPERM_W     0x20
40 #define EPERM_X     0x40
41 #define EPERM_RWX   (EPERM_R | EPERM_W | EPERM_X)
42
43 int                 file_test(const char *s, unsigned int test);
44
45 #define exists(s)   file_test(s, EFILE_ANY)
46 #define isdir(s)    file_test(s, EFILE_DIR)
47 #define isfile(s)   file_test(s, EFILE_REG)
48 #define canread(s)  file_test(s, EFILE_REG | EPERM_R)
49 #define canexec(s)  file_test(s, EFILE_REG | EPERM_X)
50
51 time_t              moddate(const char *s);
52 int                 fileinode(const char *s);
53 int                 filedev_map(int dev);
54 int                 filedev(const char *s);
55
56 int                 isabspath(const char *s);
57 const char         *fileext(const char *s);
58 char               *fileof(const char *s);
59 const char         *fullfileof(const char *s);
60
61 char               *path_test(const char *file, unsigned int test);
62 int                 path_canexec(const char *file);
63
64 #endif /* _FILE_H_ */