diff options
| author | akiyamn | 2020-09-08 23:33:53 +1000 |
|---|---|---|
| committer | akiyamn | 2020-09-08 23:33:53 +1000 |
| commit | cc006cf8239efd4f30925a1cefb0e408db3ffe0d (patch) | |
| tree | 1c4999b0556ba9bf442be9c489600cff6715c5fb /fileutil.h | |
| parent | a74edeb738198cbe7945fa3682da6e7030c13ce9 (diff) | |
| download | fit2100_ass1-cc006cf8239efd4f30925a1cefb0e408db3ffe0d.tar.gz fit2100_ass1-cc006cf8239efd4f30925a1cefb0e408db3ffe0d.zip | |
Commented a lot
Diffstat (limited to 'fileutil.h')
| -rw-r--r-- | fileutil.h | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -2,19 +2,21 @@ #define _FILEUTIL_H #define FILE_BUF_SIZE 1024 -#define DEFAULT_READ_PATH "logfile.txt" -#define NEW_FILE_PERMS 0664 +#define DEFAULT_READ_PATH "logfile.txt" // Default source path if one isn't specified +#define NEW_FILE_PERMS 0664 // -rw-r--r-- when files are created #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; - bool move_flag; - bool force_flag; - bool dir_flag; - int src_index; - int dir_index; + 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 to_stdout(char *string); @@ -24,7 +26,10 @@ void file_into_file(int source_fd, int dest_fd); 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 execute_subprogram(arguments_t args, char *argv[]); int main(int argc, char *argv[]); #endif
\ No newline at end of file |
