diff options
Diffstat (limited to 'src/create_files.c')
| -rw-r--r-- | src/create_files.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/create_files.c b/src/create_files.c new file mode 100644 index 0000000..faee27f --- /dev/null +++ b/src/create_files.c @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* create_files.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/01/16 16:23:51 by dkaiser #+# #+# */ +/* Updated: 2025/01/16 19:16:33 by dkaiser ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" +#include <unistd.h> + +void create_files(t_list *files) +{ + t_redirection *file; + int fd; + + while (files) + { + dbg("Test"); + if (files->content == NULL) + continue; + file = (t_redirection *)files->content; + if (access(file->specifier, F_OK) != -1 && access(file->specifier, W_OK) == -1) + break; + if (file->type == OUTPUT_OVERRIDE) + { + fd = open(file->specifier, O_WRONLY | O_CREAT | O_TRUNC, 0644); + close(fd); + } + else if (file->type == OUTPUT_APPEND) + { + fd = open(file->specifier, O_WRONLY | O_CREAT | O_APPEND, 0644); + close(fd); + } + /* if (files->next == NULL) */ + /* break; */ + /* if (((t_redirection *) files->next->content)->type == 0) */ + /* break; */ + files = files->next; + } +} |
