Skip to content
/ ft_ls Public

Implementation of the ls (list directory contents) command in C.

Notifications You must be signed in to change notification settings

42kmira/ft_ls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



The goal of this project was to recreate partial functionality of the program ls.

Usage: ./ft_ls [-RSUacflrtu1] [file ...]

Handles sticky bits, certain errors like permission denied, nonexistent paths, flag errors, and the flags seen above.

Implements a comparison function for the sorting of the files, which include modify time sorting, file creation, no sorting, size sorting, lexical sorting. The r flag then is applicable to all and any such function and it reverses the sorting. This is done without the need of making a comparison for the reverse sort.

Sorting is done through the use of a binary tree, meaning that inserts take O(log(N)). Due to the R it is imperative that resources are not wasted and that no memory is lost as some of these binary trees may be huge.

Output is buffered to minimize calls to write, a costly system call to the kernel. Output is colored by default, but can be toggled off by the c flag.

I have aliased ls to run my program instead, below is a gif showing the program in action.



About

Implementation of the ls (list directory contents) command in C.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published