my_ls
Présentation par Loïc BRANSTETT
Le 30/01/2019
Sommaire
- Présentation du projet
- Organisation
- Architecture
- Tests automatisé
- Bonus
- Questions ?
Présentation du projet
my_ls est un LiSting command-like.
Organisation
Architecture
Traitement d'un
path
Récupération des détails du path
Récupération des informations des éléments du dossier
Récupération des maximum en largueur des informations
Affichage des informations
Récupération des
arguments
Exemple ./my_ls -l dossier :
Architecture
my_ls.h:
#ifndef MY_LS_H_
#define MY_LS_H_
typedef struct {
int recursive;
int reverse;
int no_scan;
int long_display;
int time_sort;
int total_display;
int all_files;
int colors;
} options_t;
/* PROCESS PATHS */
int my_ls_process_path(options_t *opts, char *path);
int my_ls_process_paths(options_t *opts, int counts, char **paths);
#endif
Architecture
typedef struct {
char *acl;
char *nlinks;
char *user;
char *group;
char *size;
char *dev_minor;
char *dev_major;
char *time;
char *fullname;
} ms_element_infos_t;
typedef struct {
int max_nlinks;
int max_user;
int max_group;
int max_size;
int max_dev_minor;
int max_dev_major;
int max_time;
int total;
} ms_element_infos_max_t;
/* PRINT */
int ms_print_elements(options_t *opts, ms_element_t *head);
/* SORT */
int ms_sort_alpha(ms_element_t *a, ms_element_t *b);
int ms_sort_time(ms_element_t *a, ms_element_t *b);
int ms_sort(ms_element_t *head, ms_element_t *start,
int (*cmp)(ms_element_t *, ms_element_t *));
Tests automatisé
[===] Synthèse: Testés: 22 | Validés: 22 | Échoués: 0 | Plantages: 0
#include <criterion/criterion.h>
#include "ms.h"
Test(ms_query, simple)
{
ms_element_t *list = ms_query(".", 0, 0);
cr_assert_neq(list, NULL);
cr_assert_neq(list, list->next);
}
Test(ms_query, no_hiden_files)
{
ms_element_t *list = ms_query(".", 0, 0);
for (ms_element_t *element = list->next; element != list;
element = element->next) {
cr_assert_neq(element->name, NULL);
cr_assert_neq(element->name[0], '.');
}
}
Tests automatisé
------------------------------------------------------------------------------
GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
ms_element.c 48 46 95% 16,31
ms_infos.c 84 57 67% 21-29,33,...
ms_print.c 78 70 89% 17,41-42,...
ms_query.c 37 33 89% 33,41,44,57
ms_sort.c 21 21 100%
my_ls_path.c 66 38 57% 19-22,28,...
utils.c 31 17 54% 12,17-21,...
------------------------------------------------------------------------------
TOTAL 365 282 77%
------------------------------------------------------------------------------
Bonus
Options:
-a : ne pas ignorer les entrées débutant par .
-c : colorer la sortie
-h : afficher l'aide et quitte
Auto options:
- Sort by name
- Human readable size
Bonus
Questions ?
FIN
my_ls
By urgau-1
my_ls
- 121