Function to manipulate files. More...
Functions | |
int | files_management (t_data *data) |
Executes all the files redirection tests. | |
int | build_files_redirection (t_data *data) |
Adds files to the file redirection structure. | |
void * | add_file (t_garbage *garbage, t_command *command, t_token *token, t_file **command_file) |
Add a file to the stack given in param, each file added is at the beginning of the stack (reverse order) | |
int | build_files_data (t_command *command) |
Build the data around the files in all commands. | |
t_command * | remove_used_file_tokens (t_data *data) |
Removes all the tokens of file redirections allready used. | |
int | build_file_access (t_file *file) |
Build the file using access and check permissions. | |
char * | ft_trim_word (char *str) |
t_file * | file_parser (t_file *file) |
Parse the file structure. | |
t_tmp | create_tmp (t_garbage *garbage, char *path, int nbr_try) |
Create a tmp file, verify if it already exist, tries to open it to verify permissions, and returns the result. | |
char * | read_heredoc (t_tmp *tmp, char *delimiteur) |
Read from stdin and outputs to a file, stops reading when Ctrl+D or when a delimitor is found. | |
int | verify_access (t_garbage *garbage, t_command *command) |
Verify that all files are valid if at least one file is invalid, modifies the boolean in command but still return 0. | |
t_file * | search_last_file (t_file *file, t_file *already_searched) |
Return the last file that is not already_searched. | |
int | fill_heredocs (t_garbage *garbage, t_command *command) |
Fill all the heredocs in the correct order. | |
int | open_file_with_rights (t_garbage *garbage, t_file *file, t_bool in_out) |
Open a file with it's rights (permissions) | |
void | read_write_to (t_garbage *garbage, t_command *command, t_bool in_out) |
Opens the files to read and writes. | |
void | fd_default (t_command *command) |
Put the fds in command to there default values. | |
Function to manipulate files.
void * add_file | ( | t_garbage * | garbage, |
t_command * | command, | ||
t_token * | token, | ||
t_file ** | command_file ) |
Add a file to the stack given in param, each file added is at the beginning of the stack (reverse order)
garbage | garbage structure |
command | command structure |
token | token containing str informations |
command_file | stack to assign a file |
int build_file_access | ( | t_file * | file | ) |
Build the file using access and check permissions.
file | file structure |
int build_files_data | ( | t_command * | command | ) |
Build the data around the files in all commands.
command | file structure |
int build_files_redirection | ( | t_data * | data | ) |
Adds files to the file redirection structure.
data | data structure |
Create a tmp file, verify if it already exist, tries to open it to verify permissions, and returns the result.
garbage | garbage structure |
path | path where to create the file |
nbr_try | number of try to create a tmp file |
void fd_default | ( | t_command * | command | ) |
Put the fds in command to there default values.
command | command structure |
Parse the file structure.
file | file structure |
int files_management | ( | t_data * | data | ) |
Executes all the files redirection tests.
data | data structure |
Fill all the heredocs in the correct order.
garbage | garbage structure |
command | command structure |
char * ft_trim_word | ( | char * | str | ) |
Open a file with it's rights (permissions)
garbage | garbage structure |
file | file structure |
in_out | 0 = IN, 1 = OUT |
char * read_heredoc | ( | t_tmp * | tmp, |
char * | delimitor ) |
Read from stdin and outputs to a file, stops reading when Ctrl+D or when a delimitor is found.
tmp | structure for heredocs |
delimitor | string to know when to stop reading |
Opens the files to read and writes.
garbage | garbage structure |
command | command structure |
in_out | 0 = IN, 1 = OUT |
Removes all the tokens of file redirections allready used.
data | data structure |
Return the last file that is not already_searched.
file | file structure |
already_searched | previous file from search |