61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
#pragma once
|
|
|
|
#include <dirent.h>
|
|
#include <errno.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <pwd.h>
|
|
#include <grp.h>
|
|
#include <time.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
typedef struct {
|
|
_Bool l;
|
|
_Bool a;
|
|
_Bool R;
|
|
_Bool r;
|
|
_Bool t;
|
|
_Bool dashdash;
|
|
int error[2];
|
|
} flags_t;
|
|
|
|
typedef struct {
|
|
DIR *dir;
|
|
char *path;
|
|
char *name;
|
|
_Bool is_file;
|
|
struct stat stat;
|
|
struct stat lstat;
|
|
struct passwd *psswd;
|
|
struct group *grp;
|
|
} dir_t;
|
|
|
|
extern flags_t flags;
|
|
extern struct winsize win;
|
|
|
|
#define true 1
|
|
#define false 0
|
|
|
|
// Parsing
|
|
void get_flags(char **argv);
|
|
void parsing(char **argv, t_list ***files, t_list ***dirs, i32 *max_size, i32 *len, i32 *error);
|
|
dir_t *get_directory_files(char *path);
|
|
|
|
// Display
|
|
void display_name(dir_t *dir);
|
|
void display_file(dir_t *dir, i32 max_size);
|
|
i32 display_files(t_list **files);
|
|
void display_directory(dir_t *dir);
|
|
i32 display_files_stat(t_list **files);
|
|
void display_single_stat(dir_t *dir, i32 max_size, i32 max_nlink);
|
|
void space_between_files(t_list **files, dir_t *file);
|
|
|
|
// Directory
|
|
void strmode(mode_t mode, char *buf);
|
|
void delete_directory(void *content);
|
|
t_list **get_all_in(dir_t *dir);
|
|
void add_sort(t_list **head, dir_t *new_dir, _Bool file_priority);
|
|
|
|
// Free
|
|
void free_files(t_list **files);
|