aboutsummaryrefslogtreecommitdiff
path: root/src/system.h
blob: 950a82a2621d968bffd13d9d08670f300a18c62b (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
#ifndef SYSTEM_H
#define SYSTEM_H

/* Routines for interacting with the system, mainly executing processes and
 * dealing with the file system. */

/* Used when encrypting or decrypting a file, see the copy_file_with_encryption
 * function. */
enum encrypt {
	ENCRYPT,
	DECRYPT
};

/* Return whether PATH exists in the file system. Exit if any non-"file not
 * fount" error occurs. */
int file_exists(const char *path);

/* Copy the file whose path is IN at path OUT. OUT is created or overwritten if
 * needed. */
void copy_file(const char *in, const char *out);

/* Like copy_file but with encryption, which is managed using GPG.  */
void copy_file_with_encryption(const char *in, const char *out, enum encrypt encrypt);

/* Execute command in a child process, then wait for the child to exit before
 * returning. If any error occurs, including in the child process, then if EXIT
 * is non-zero, exit, else return -1. Return 0 on success. */
int ftag_execvp(char *const *cmd, int can_exit);

#endif