build: adding all the new files on the filelist

feat: adding the command asked by maiboyer
This commit is contained in:
Raphael 2024-09-17 22:40:43 +02:00
parent 9fc0bc4a1f
commit da223422b0
7 changed files with 96 additions and 22 deletions

View file

@ -1,33 +1,34 @@
SRC_FILES = \
builtins/_debug \
builtins/cd \
builtins/_debug \
builtins/echo \
builtins/env \
builtins/exit \
builtins/export \
builtins/pwd \
builtins/unset \
run_arithmetic/_get_op \
run_arithmetic/_run_arith \
run_arithmetic/_to_ast_node \
_read_dir \
run_arithmetic/arithmetic \
run_arithmetic/arithmetic_operation \
run_arithmetic/_get_op \
run_arithmetic/operator_bis \
run_arithmetic/_run_arith \
run_arithmetic/_to_ast_node \
run_ast/_ast_into_str \
run_ast/_ast_into_str2 \
run_ast/_ast_into_str3 \
run_ast/_ast_into_str4 \
run_ast/_run_exit_code \
run_ast/_run_exp_operators \
run_ast/_spawn_cmd \
run_ast/run_builtins \
run_ast/run_cmd_sub \
run_ast/run_command \
run_ast/_run_exit_code \
run_ast/run_expansion \
run_ast/run_expansion_builtin \
run_ast/_run_exp_operators \
run_ast/run_list \
run_ast/run_pipeline \
run_ast/run_program \
run_ast/run_subshell \
run_ast/run_words \
run_ast/_spawn_cmd \

73
exec/src/_read_dir.c Normal file
View file

@ -0,0 +1,73 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* _read_dir.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/17 21:43:33 by rparodi #+# #+# */
/* Updated: 2024/09/17 22:39:54 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <errno.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include "app/env.h"
#include "exec/_run_ast.h"
#include "me/fs/fs.h"
#include "me/os/os.h"
#include "me/str/str.h"
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#include "line/line.h"
#include "me/string/string.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include "exec/builtins.h"
#include "me/printf/printf.h"
#include "me/string/string.h"
#include "me/types.h"
/**
* @brief the pushing files on vector
*
* @param path path to parse
* @param out the return value
* @return ERROR (1) / NO_ERROR (0)
*/
t_error listing_files(t_string path, t_vec_str *out)
{
DIR *tmp;
struct dirent *entry;
tmp = opendir(path.buf);
if (tmp == NULL)
return (ERROR);
while ((entry = readdir(tmp)) != NULL)
vec_str_push(out, entry->d_name);
return (NO_ERROR);
}
/**
* @brief list all files in the current directory
*
* @param out the return value
* @return ERROR (1) / NO_ERROR (0)
*/
t_error list_files_in_current_directory(t_vec_str *out)
{
t_vec_str *tmp;
t_string path;
(void)out;
tmp = NULL;
while (getcwd(path.buf, path.capacity - 1) == NULL)
if (errno == ERANGE)
string_reserve(&path, path.capacity * 3);
if (!listing_files(path, tmp))
return (NO_ERROR);
return (out = tmp, NO_ERROR);
}