blob: 7be85276ad89b998812b9bfc33f0bc74dd98e350 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#ifndef _SK_UTIL_FS_H
#define _SK_UTIL_FS_H
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <pwd.h>
#include <sys/stat.h>
#if HAVE_STDBOOL_H
#include <stdbool.h>
#endif
/**
* exists:
* Check if a given pathname exists.
*
* @param pathname: the path to check
* @return true if @pathname exists, false otherwise.
*/
#define exists(pathname) (0 == access(pathname, F_OK))
/**
* is_dir:
* Check if a given pathname is a directory.
*
* @param pathname: the path to check
* @return true if @pathname exists and is a directory, false otherwise.
*/
bool is_dir(const char *restrict pathname);
/**
* myhome:
* Returns a pointer to a string containing the current user’s home
* directory.
* The returned pointer points to a static location (don’t free() it) and
* may be changed on future invocations.
*
* This function makes sure that the returned string is null-terminated and
* truncates the result to fit within PATH_MAX if necessary.
*
* @returns home dir
*/
const char *myhome();
#endif
|