summaryrefslogtreecommitdiff
path: root/fileutil.h
blob: f5783a003a527f1bb09b10f2eb9dc19fb8efe7f9 (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
// fileutil.h

#ifndef _FILEUTIL_H
#define _FILEUTIL_H

#define DEFAULT_READ_PATH "logfile.txt" // Default source path if one isn't specified
#define MIN_NUM_OF_ARGS 1
#define MAX_NUM_OF_ARGS 6

typedef enum {false, true} bool;

// A struct type which represents the arguments/flags provided to the program
typedef struct arguments_t {
    bool valid; // Is this a valid combination of arguments?
    bool move_flag; // Is the move flag specified? (-M)
    bool force_flag; // Is the force flag specified? (-F)
    bool dir_flag; // Is the directory flag specified? (-d)
    int src_index; // Index in the provided arguments (argv) of the source path string
    int dir_index; // Index in the provided arguments (argv) of the directory path string
} arguments_t;

void print_file(char *read_path);
void copy_file(char *read_path, char *write_path, bool overwrite);
char* get_filename(char *full_path);
bool is_a_path(char* string);
void copy_into_dir(char *file_path, char *dir_path, bool move, bool overwrite);
arguments_t parse_arguments(int argc, char **argv);
void validate_arguments(arguments_t *args, int argc, char **argv);
void execute_subprogram(arguments_t args, char *argv[]);
int main(int argc, char *argv[]);

#endif