ready to push
This commit is contained in:
parent
bc038dbe4a
commit
e61be29d48
13 changed files with 51 additions and 162 deletions
3
ls/.gitmodules
vendored
3
ls/.gitmodules
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
[submodule "libft"]
|
|
||||||
path = libft
|
|
||||||
url = https://github.com/jzck/libft
|
|
||||||
4
ls/.tags
4
ls/.tags
|
|
@ -29,12 +29,12 @@ ft_ls_long_total src/lib_ls_long2.c /^void ft_ls_long_total(t_list *ent)$/
|
||||||
ft_ls_long_type src/lib_ls_long.c /^void ft_ls_long_type(mode_t m)$/
|
ft_ls_long_type src/lib_ls_long.c /^void ft_ls_long_type(mode_t m)$/
|
||||||
ft_ls_long_xattr src/lib_ls_long2.c /^int ft_ls_long_xattr(mode_t m, char *path)$/
|
ft_ls_long_xattr src/lib_ls_long2.c /^int ft_ls_long_xattr(mode_t m, char *path)$/
|
||||||
ft_ls_parse src/lib_parse.c /^int ft_ls_parse(int ac, char **av, t_list **dir,/
|
ft_ls_parse src/lib_parse.c /^int ft_ls_parse(int ac, char **av, t_list **dir,/
|
||||||
ft_ls_parse_files src/lib_parse.c /^static void ft_ls_parse_files(int ac, char **av, i/
|
ft_ls_parse_files src/lib_parse.c /^static void ft_ls_parse_files(char **av, int opts,/
|
||||||
ft_ls_parse_options src/lib_parse.c /^static int ft_ls_parse_options(int ac, char **av, /
|
ft_ls_parse_options src/lib_parse.c /^static int ft_ls_parse_options(int ac, char **av, /
|
||||||
ft_ls_postname src/ft_ls_postname.c /^void ft_ls_postname(mode_t m, int opts)$/
|
ft_ls_postname src/ft_ls_postname.c /^void ft_ls_postname(mode_t m, int opts)$/
|
||||||
ft_ls_short src/ft_ls_short.c /^void ft_ls_short(t_list *ent, t_lsdata *topdir, in/
|
ft_ls_short src/ft_ls_short.c /^void ft_ls_short(t_list *ent, t_lsdata *topdir, in/
|
||||||
ft_lsdata_cmp0 src/lib_lsdata.c /^int ft_lsdata_cmp0(t_lsdata *data, char *dataref)/
|
ft_lsdata_cmp0 src/lib_lsdata.c /^int ft_lsdata_cmp0(t_lsdata *data, char *dataref)/
|
||||||
ft_lsdata_cmpA src/lib_lsdata.c /^int ft_lsdata_cmpA(t_lsdata *data, char *dataref)/
|
|
||||||
ft_lsdata_cmp_name src/lib_lsdata.c /^int ft_lsdata_cmp_name(t_lsdata *dat1, t_lsdata */
|
ft_lsdata_cmp_name src/lib_lsdata.c /^int ft_lsdata_cmp_name(t_lsdata *dat1, t_lsdata */
|
||||||
ft_lsdata_cmp_size src/lib_lsdata.c /^int ft_lsdata_cmp_size(t_lsdata *dat1, t_lsdata */
|
ft_lsdata_cmp_size src/lib_lsdata.c /^int ft_lsdata_cmp_size(t_lsdata *dat1, t_lsdata */
|
||||||
|
ft_lsdata_cmpa src/lib_lsdata.c /^int ft_lsdata_cmpa(t_lsdata *data, char *dataref)/
|
||||||
ft_lsdata_filename src/lib_lsdata.c /^void ft_lsdata_filename(t_lsdata *data, t_lsdata */
|
ft_lsdata_filename src/lib_lsdata.c /^void ft_lsdata_filename(t_lsdata *data, t_lsdata */
|
||||||
|
|
|
||||||
16
ls/Makefile
16
ls/Makefile
|
|
@ -1,9 +1,9 @@
|
||||||
NAME = ft_ls
|
NAME = ft_ls
|
||||||
CC = gcc
|
CC = gcc
|
||||||
TAGFILE = .tags
|
|
||||||
|
|
||||||
D_SRC = src
|
D_SRC = src
|
||||||
F_SRC := $(shell ls -1 $(D_SRC) | grep "\.c$$")
|
F_SRC := $(shell ls -1 $(D_SRC) | grep "\.c$$")
|
||||||
|
F_SRC := ft_dir_get_ents.c ft_ent_free.c ft_ent_get_dirs.c ft_ent_has_dir.c ft_ls.c ft_ls_color.c ft_ls_long.c ft_ls_postname.c ft_ls_short.c lib_ent.c lib_error.c lib_ls_long.c lib_ls_long2.c lib_lsdata.c lib_parse.c lib_time.c main.c
|
||||||
DF_SRC := $(addprefix $(D_SRC)/, $(F_SRC))
|
DF_SRC := $(addprefix $(D_SRC)/, $(F_SRC))
|
||||||
|
|
||||||
D_OBJ = obj
|
D_OBJ = obj
|
||||||
|
|
@ -14,18 +14,14 @@ D_INC = includes libft/includes
|
||||||
O_INC = $(addprefix -I, $(D_INC))
|
O_INC = $(addprefix -I, $(D_INC))
|
||||||
|
|
||||||
W_FLAGS = -Wall -Wextra -Werror
|
W_FLAGS = -Wall -Wextra -Werror
|
||||||
D_FLAGS = -g
|
D_FLAGS =
|
||||||
|
|
||||||
MKDIR = mkdir -p
|
MKDIR = mkdir -p
|
||||||
RM = /bin/rm -rf
|
RM = /bin/rm -rf
|
||||||
|
|
||||||
.PHONY: all clean fclean re tags test libft
|
.PHONY: all clean fclean re
|
||||||
|
|
||||||
all: $(NAME) $(TAGFILE)
|
all: $(NAME)
|
||||||
|
|
||||||
$(TAGFILE): $(D_SRC)/*.c
|
|
||||||
@ctags -f $(TAGFILE) $(addprefix $(D_SRC)/, $(F_SRC))
|
|
||||||
@echo "Making tags..."
|
|
||||||
|
|
||||||
$(D_OBJ)/%.o: $(D_SRC)/%.c $(D_INC)
|
$(D_OBJ)/%.o: $(D_SRC)/%.c $(D_INC)
|
||||||
@$(MKDIR) $(D_OBJ)
|
@$(MKDIR) $(D_OBJ)
|
||||||
|
|
@ -35,15 +31,13 @@ $(D_OBJ)/%.o: $(D_SRC)/%.c $(D_INC)
|
||||||
libft:
|
libft:
|
||||||
@$(MAKE) -C libft/ 2>/dev/null
|
@$(MAKE) -C libft/ 2>/dev/null
|
||||||
|
|
||||||
$(NAME): libft $(DF_OBJ) libft/libft.a
|
$(NAME): $(DF_OBJ) libft
|
||||||
$(CC) $(O_INC) -Llibft -lft $(W_FLAGS) $(DF_OBJ) -o $@ $(D_FLAGS)
|
$(CC) $(O_INC) -Llibft -lft $(W_FLAGS) $(DF_OBJ) -o $@ $(D_FLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(D_OBJ)
|
$(RM) $(D_OBJ)
|
||||||
@$(MAKE) -C libft clean 2>/dev/null
|
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
$(RM) $(NAME)
|
$(RM) $(NAME)
|
||||||
@$(MAKE) -C libft fclean 2>/dev/null
|
|
||||||
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
|
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
let SessionLoad = 1
|
|
||||||
if &cp | set nocp | endif
|
|
||||||
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
|
|
||||||
let v:this_session=expand("<sfile>:p")
|
|
||||||
silent only
|
|
||||||
cd ~/
|
|
||||||
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
|
||||||
let s:wipebuf = bufnr('%')
|
|
||||||
endif
|
|
||||||
set shortmess=aoO
|
|
||||||
badd +1 src/lib_ls_long2.c
|
|
||||||
badd +27 src/ft_ls_long.c
|
|
||||||
badd +25 includes/ft_ls.h
|
|
||||||
badd +60 ~/.tmux.conf
|
|
||||||
badd +52 src/lib_ls_long.c
|
|
||||||
badd +35 src/lib_lsdata.c
|
|
||||||
badd +76 src/lib_parse.c
|
|
||||||
badd +22 libft/src/ft_printf/lib_pad.c
|
|
||||||
badd +19 libft/src/ft_printf/lib_pad_sharp.c
|
|
||||||
badd +9 libft/src/lst/ft_lst_filter.c
|
|
||||||
badd +14 src/lib_dirents.c
|
|
||||||
badd +21 src/main.c
|
|
||||||
badd +30 src/ft_ls.c
|
|
||||||
badd +21 src/ft_ent_free.c
|
|
||||||
badd +1 Makefile
|
|
||||||
badd +16 src/lib_error.c
|
|
||||||
badd +32 src/lib_dirs.c
|
|
||||||
badd +31 src/ft_dir_get_ents.c
|
|
||||||
badd +33 libft/src/ft_printf/ft_printf.c
|
|
||||||
badd +43 libft/includes/ft_printf.h
|
|
||||||
badd +2 libft/src/printing/ft_putstr_fd.c
|
|
||||||
badd +11 libft/includes/libft.h
|
|
||||||
badd +2 libft/src/ft_printf/lib_fmt.c
|
|
||||||
badd +1 src/.lib_dirents.c.swo
|
|
||||||
badd +1 ft_ls
|
|
||||||
badd +1 libft/src/dlst/ft_dlstdel.c
|
|
||||||
badd +19 libft/src/lst/ft_lstdel.c
|
|
||||||
badd +21 libft/src/path/ft_path_notdir.c
|
|
||||||
badd +1 libft/src/mem/ft_memcpy.c
|
|
||||||
badd +19 libft/src/mem/ft_memdel.c
|
|
||||||
badd +31 libft/src/lst/ft_lst_delif.c
|
|
||||||
badd +22 libft/src/lst/ft_lstdelone.c
|
|
||||||
badd +25 libft/src/lst/ft_lst_removeif.c
|
|
||||||
badd +42 ~/.vimrc
|
|
||||||
badd +12 src/ft_ent_has_dir.c
|
|
||||||
badd +35 src/ft_ent_get_dirs.c
|
|
||||||
badd +19 src/lib_ent.c
|
|
||||||
badd +11 .Makefile.swp
|
|
||||||
badd +18 ~/dotfiles/vim.symlink/plugins.vim
|
|
||||||
badd +22 libft/src/str/ft_strsub.c
|
|
||||||
args src/lib_ls_long2.c
|
|
||||||
edit src/main.c
|
|
||||||
set splitbelow splitright
|
|
||||||
set nosplitbelow
|
|
||||||
set nosplitright
|
|
||||||
wincmd t
|
|
||||||
set winheight=1 winwidth=1
|
|
||||||
argglobal
|
|
||||||
setlocal fdm=manual
|
|
||||||
setlocal fde=0
|
|
||||||
setlocal fmr={{{,}}}
|
|
||||||
setlocal fdi=#
|
|
||||||
setlocal fdl=0
|
|
||||||
setlocal fml=1
|
|
||||||
setlocal fdn=20
|
|
||||||
setlocal fen
|
|
||||||
silent! normal! zE
|
|
||||||
let s:l = 1 - ((0 * winheight(0) + 40) / 81)
|
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
|
||||||
exe s:l
|
|
||||||
normal! zt
|
|
||||||
1
|
|
||||||
normal! 0
|
|
||||||
tabnext 1
|
|
||||||
if exists('s:wipebuf')
|
|
||||||
silent exe 'bwipe ' . s:wipebuf
|
|
||||||
endif
|
|
||||||
unlet! s:wipebuf
|
|
||||||
set winheight=1 winwidth=20 shortmess=filnxtToO
|
|
||||||
let s:sx = expand("<sfile>:p:r")."x.vim"
|
|
||||||
if file_readable(s:sx)
|
|
||||||
exe "source " . fnameescape(s:sx)
|
|
||||||
endif
|
|
||||||
let &so = s:so_save | let &siso = s:siso_save
|
|
||||||
let g:this_session = v:this_session
|
|
||||||
let g:this_obsession = v:this_session
|
|
||||||
let g:this_obsession_status = 2
|
|
||||||
doautoall SessionLoadPost
|
|
||||||
unlet SessionLoad
|
|
||||||
" vim: set ft=vim :
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 15:10:03 by jhalford #+# #+# */
|
/* Created: 2016/11/07 15:10:03 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 18:26:44 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 13:09:06 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
1
ls/libft
1
ls/libft
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a08d8287e8e798ca7e18f9c4de9fbfa98aa395aa
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/25 13:39:11 by jhalford #+# #+# */
|
/* Created: 2016/11/25 13:39:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 16:00:01 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 11:57:02 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,31 +14,24 @@
|
||||||
|
|
||||||
void ft_ls_color(mode_t m)
|
void ft_ls_color(mode_t m)
|
||||||
{
|
{
|
||||||
char fg[20];
|
t_color color;
|
||||||
char bg[20];
|
|
||||||
|
|
||||||
ft_strcpy(fg, FG_DEFAULT);
|
ft_color_mk(&color, FG_DEFAULT, BG_DEFAULT);
|
||||||
ft_strcpy(bg, BG_DEFAULT);
|
ft_color_mkif(&color, S_ISDIR(m), FG_BLUE, BG_DEFAULT);
|
||||||
ft_strcpy(fg, S_ISDIR(m) ? FG_BLUE : fg);
|
ft_color_mkif(&color, S_ISLNK(m), FG_MAGENTA, BG_DEFAULT);
|
||||||
ft_strcpy(fg, S_ISLNK(m) ? FG_MAGENTA : fg);
|
ft_color_mkif(&color, S_ISLNK(m), FG_MAGENTA, BG_DEFAULT);
|
||||||
ft_strcpy(fg, S_ISSOCK(m) ? FG_GREEN : fg);
|
ft_color_mkif(&color, S_ISSOCK(m), FG_GREEN, BG_DEFAULT);
|
||||||
ft_strcpy(fg, S_ISFIFO(m) ? FG_YELLOW : fg);
|
ft_color_mkif(&color, S_ISFIFO(m), FG_YELLOW, BG_DEFAULT);
|
||||||
ft_strcpy(fg, S_ISREG(m) && (S_IXUGO & m) ? FG_RED : fg);
|
ft_color_mkif(&color, S_ISREG(m) && (S_IXUGO & m), FG_RED, BG_DEFAULT);
|
||||||
ft_strcpy(fg, S_ISBLK(m) ? FG_BLUE : fg);
|
ft_color_mkif(&color, S_ISBLK(m), FG_BLUE, BG_CYAN);
|
||||||
ft_strcpy(bg, S_ISBLK(m) ? BG_CYAN : bg);
|
ft_color_mkif(&color, S_ISCHR(m), FG_BLUE, BG_YELLOW);
|
||||||
ft_strcpy(fg, S_ISCHR(m) ? FG_BLUE : fg);
|
ft_color_mkif(&color, S_ISREG(m) && (S_IXUGO & m) && (S_ISGID & m),
|
||||||
ft_strcpy(bg, S_ISCHR(m) ? BG_YELLOW : bg);
|
FG_BLACK, BG_CYAN);
|
||||||
ft_strcpy(fg, S_ISREG(m) && (S_IXUGO & m) &&
|
ft_color_mkif(&color, S_ISREG(m) && (S_IXUGO & m) && (S_ISUID & m),
|
||||||
(S_ISGID & m) ? FG_BLACK : fg);
|
FG_BLACK, BG_RED);
|
||||||
ft_strcpy(bg, S_ISREG(m) && (S_IXUGO & m) &&
|
ft_color_mkif(&color, S_ISDIR(m) && (S_IWOTH & m) && (S_ISVTX & m),
|
||||||
(S_ISGID & m) ? BG_CYAN : bg);
|
FG_BLACK, BG_GREEN);
|
||||||
ft_strcpy(fg, S_ISREG(m) && (S_IXUGO & m) &&
|
ft_color_mkif(&color, S_ISDIR(m) && (S_IWOTH & m) && !(S_ISVTX & m),
|
||||||
(S_ISUID & m) ? FG_BLACK : fg);
|
FG_BLACK, BG_YELLOW);
|
||||||
ft_strcpy(bg, S_ISREG(m) && (S_IXUGO & m) &&
|
ft_color_set(color);
|
||||||
(S_ISUID & m) ? BG_RED : bg);
|
|
||||||
ft_strcpy(fg, S_ISDIR(m) && (S_IWOTH & m) && (S_ISVTX & m) ? FG_BLACK : fg);
|
|
||||||
ft_strcpy(bg, S_ISDIR(m) && (S_IWOTH & m) && (S_ISVTX & m) ? BG_GREEN : bg);
|
|
||||||
ft_strcpy(fg, S_ISDIR(m) && (S_IWOTH & m) && !(S_ISVTX & m) ? FG_BLACK : fg);
|
|
||||||
ft_strcpy(bg, S_ISDIR(m) && (S_IWOTH & m) && !(S_ISVTX & m) ? BG_YELLOW : bg);
|
|
||||||
ft_color_set(fg, bg);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 14:57:43 by jhalford #+# #+# */
|
/* Created: 2016/11/07 14:57:43 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 13:08:52 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 11:57:23 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,18 +22,15 @@ void ft_error_access(char *s)
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "ls: ");
|
ft_dprintf(2, "ls: ");
|
||||||
perror(ft_path_notdir(s));
|
perror(ft_path_notdir(s));
|
||||||
/* ft_dprintf(2, LS_MSG_ACC_ERR, ft_path_notdir(s)); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_error_dir(char *s)
|
void ft_error_dir(char *s)
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "ls: ");
|
ft_dprintf(2, "ls: ");
|
||||||
if (*s)
|
if (*s)
|
||||||
/* ft_dprintf(2, LS_MSG_FILE_ERR, s); */
|
|
||||||
perror(s);
|
perror(s);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* ft_dprintf(2, LS_MSG_FILE_ERR, "fts_open"); */
|
|
||||||
perror("fts_open");
|
perror("fts_open");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 14:59:51 by jhalford #+# #+# */
|
/* Created: 2016/11/07 14:59:51 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 18:31:12 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 11:57:47 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -55,7 +55,8 @@ void ft_ls_long_date(struct stat *stat, int opts)
|
||||||
ft_printf(" %s %s %s:%s:%s %s", time->month, time->day, time->hour,
|
ft_printf(" %s %s %s:%s:%s %s", time->month, time->day, time->hour,
|
||||||
time->min, time->sec, time->year);
|
time->min, time->sec, time->year);
|
||||||
else if (ft_time_isrecent(st_time))
|
else if (ft_time_isrecent(st_time))
|
||||||
ft_printf(" %s %s %s:%s", time->month, time->day, time->hour, time->min);
|
ft_printf(" %s %s %s:%s",
|
||||||
|
time->month, time->day, time->hour, time->min);
|
||||||
else
|
else
|
||||||
ft_printf(" %s %s %s", time->month, time->day, time->year);
|
ft_printf(" %s %s %s", time->month, time->day, time->year);
|
||||||
ft_mytime_free(&time);
|
ft_mytime_free(&time);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 15:01:01 by jhalford #+# #+# */
|
/* Created: 2016/11/07 15:01:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 17:22:53 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 13:08:09 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -55,15 +55,15 @@ int ft_ls_long_xattr(mode_t m, char *path)
|
||||||
{
|
{
|
||||||
char x;
|
char x;
|
||||||
acl_t acl;
|
acl_t acl;
|
||||||
acl_entry_t acl_entry;
|
|
||||||
|
|
||||||
acl = acl_get_file(path, ACL_TYPE_DEFAULT | ACL_TYPE_ACCESS);
|
|
||||||
if ((acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry)) == 0)
|
|
||||||
x = '+';
|
|
||||||
else if (!S_ISBLK(m) && !S_ISCHR(m))
|
|
||||||
x = ft_xattr_count(path) > 0 ? '@' : ' ';
|
|
||||||
else
|
|
||||||
x = ' ';
|
x = ' ';
|
||||||
|
if (!S_ISBLK(m) && !S_ISCHR(m) && ft_xattr_count(path) > 0)
|
||||||
|
x = '@';
|
||||||
|
else if ((acl = acl_get_file(path, ACL_TYPE_EXTENDED)))
|
||||||
|
{
|
||||||
|
x = '+';
|
||||||
|
acl_free((void*)acl);
|
||||||
|
}
|
||||||
ft_putchar(x);
|
ft_putchar(x);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
@ -107,11 +107,10 @@ int ft_ls_long_pads(t_list *ent, t_pads *pads)
|
||||||
FT_MAX_WR(pads->nlink, (int)ft_uilen(stat.st_nlink));
|
FT_MAX_WR(pads->nlink, (int)ft_uilen(stat.st_nlink));
|
||||||
FT_MAX_WR(pads->size, (int)ft_ilen(stat.st_size));
|
FT_MAX_WR(pads->size, (int)ft_ilen(stat.st_size));
|
||||||
if (S_ISCHR(stat.st_mode) || S_ISBLK(stat.st_mode))
|
if (S_ISCHR(stat.st_mode) || S_ISBLK(stat.st_mode))
|
||||||
{
|
|
||||||
FT_MAX_WR(pads->minor, (int)ft_ilen(minor(stat.st_rdev)));
|
FT_MAX_WR(pads->minor, (int)ft_ilen(minor(stat.st_rdev)));
|
||||||
|
if (S_ISCHR(stat.st_mode) || S_ISBLK(stat.st_mode))
|
||||||
FT_MAX_WR(pads->major, (int)ft_ilen(major(stat.st_rdev)));
|
FT_MAX_WR(pads->major, (int)ft_ilen(major(stat.st_rdev)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
pads->size = FT_MAX(pads->size, pads->minor ?
|
pads->size = FT_MAX(pads->size, pads->minor ?
|
||||||
pads->minor + pads->major + 3 : pads->size);
|
pads->minor + pads->major + 3 : pads->size);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 14:59:09 by jhalford #+# #+# */
|
/* Created: 2016/11/07 14:59:09 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 18:26:53 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 11:15:37 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,13 +17,13 @@ void ft_lsdata_filename(t_lsdata *data, t_lsdata *topdir, int opts)
|
||||||
struct dirent *dirent;
|
struct dirent *dirent;
|
||||||
|
|
||||||
dirent = data->dirent;
|
dirent = data->dirent;
|
||||||
if (opts & OPTS_UG)
|
if (opts & OPTS_UG && isatty(1))
|
||||||
ft_ls_color(data->stat.st_mode);
|
ft_ls_color(data->stat.st_mode);
|
||||||
if (data->path)
|
if (data->path)
|
||||||
ft_printf("%s", topdir ? ft_path_notdir(data->path) : data->path);
|
ft_printf("%s", topdir ? ft_path_notdir(data->path) : data->path);
|
||||||
else if (dirent && *dirent->d_name)
|
else if (dirent && *dirent->d_name)
|
||||||
ft_printf("%s", dirent->d_name);
|
ft_printf("%s", dirent->d_name);
|
||||||
if (opts & OPTS_UG)
|
if (opts & OPTS_UG && isatty(1))
|
||||||
ft_color_reset();
|
ft_color_reset();
|
||||||
ft_ls_postname(data->stat.st_mode, opts);
|
ft_ls_postname(data->stat.st_mode, opts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 15:02:46 by jhalford #+# #+# */
|
/* Created: 2016/11/07 15:02:46 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 18:31:15 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 12:49:32 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ t_opts g_opts[] =
|
||||||
{'T', OPTS_UT, 0},
|
{'T', OPTS_UT, 0},
|
||||||
{'U', OPTS_UU, TIME_MASK},
|
{'U', OPTS_UU, TIME_MASK},
|
||||||
{'a', OPTS_LA, 0},
|
{'a', OPTS_LA, 0},
|
||||||
{'c', OPTS_LC, 0},
|
{'c', OPTS_LC, TIME_MASK},
|
||||||
{'d', OPTS_LD, 0},
|
{'d', OPTS_LD, 0},
|
||||||
{'f', OPTS_LF, 0},
|
{'f', OPTS_LF, 0},
|
||||||
{'g', OPTS_LG, 0},
|
{'g', OPTS_LG, 0},
|
||||||
|
|
@ -36,15 +36,14 @@ t_opts g_opts[] =
|
||||||
{0, 0, 0},
|
{0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void ft_ls_parse_files(char **av, int opts, t_list **dir, t_list **ent)
|
||||||
static void ft_ls_parse_files(int ac, char **av, int opts, t_list **dir, t_list **ent)
|
|
||||||
{
|
{
|
||||||
t_lsdata data;
|
t_lsdata data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
data.dirent = NULL;
|
data.dirent = NULL;
|
||||||
i = -1;
|
i = -1;
|
||||||
while (++i < ac)
|
while (av[++i])
|
||||||
{
|
{
|
||||||
if (stat(av[i], &data.stat) < 0)
|
if (stat(av[i], &data.stat) < 0)
|
||||||
if (lstat(av[i], &data.stat) < 0)
|
if (lstat(av[i], &data.stat) < 0)
|
||||||
|
|
@ -128,8 +127,8 @@ int ft_ls_parse(int ac, char **av, t_list **dir, t_list **ent)
|
||||||
opts |= (ac - i > 1) ? OPTS_HEAD : 0;
|
opts |= (ac - i > 1) ? OPTS_HEAD : 0;
|
||||||
ft_sstrsort(av + i, &ft_strcmp);
|
ft_sstrsort(av + i, &ft_strcmp);
|
||||||
if (i == ac)
|
if (i == ac)
|
||||||
ft_ls_parse_files(1, (char*[2]){"."}, opts,dir, ent);
|
ft_ls_parse_files((char *[2]){"."}, opts, dir, ent);
|
||||||
else
|
else
|
||||||
ft_ls_parse_files(ac - i, av + i, opts, dir, ent);
|
ft_ls_parse_files(av + i, opts, dir, ent);
|
||||||
return (opts);
|
return (opts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 15:00:15 by jhalford #+# #+# */
|
/* Created: 2016/11/07 15:00:15 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/25 10:49:54 by jhalford ### ########.fr */
|
/* Updated: 2016/11/27 12:06:22 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue