lgutter / ft_ls Goto Github PK
View Code? Open in Web Editor NEWThe Codam/42 Project ft_ls
The Codam/42 Project ft_ls
We will need to be able to store any info about a file/directory, so we need structs for this.
this function takes a 't_file_info *' to the start of the list, and sorts the list depending on the provided options:
default sort is lexicographical, lower ascii values to higher.
-t sort by modification date, default last modified first.
-r reverses the sort, works with the t option aswell.
when running \ls -1 -Rarl test_files
against ./ft_ls -Rarl test_files
on my computer:
there is a link without permissions in the subfolder files_for_tests
called bullshitnothere
.
there is also a directory without permissions called nopermissions
.
the real ls prints the permission errors as:
ls: files_for_tests/bullshitnothere: Permission denied
ls: nopermissions: Permission denied
while we print the errors as:
ft_ls: bullshitnothere: Permission denied
ft_ls: nopermissions: Permission denied
I don't really understand why the real ls prints these 2 errors differently...
right now, if you run ./ft_ls
without arguments, we don't do anything.
we should handle this as if we ran ./ft_ls .
.
For any file/dir name we need a function that can make a struct with all the relevant info.
for example: ./ft_ls file1 file3 directory1 file2
should output:
file1
file2
file3
directory1:
subdir1
file4
file5
when the -R flag is provided, (./ft_ls -R file1 file3 directory1 file2
)it would look like:
file1
file2
file3
directory1:
subdir1
file4
file5
directory1/subdir1:
file6
file7
so behaviour directly with arguments is a little trickier.
in ft_ls there is an exception that triggers if there is a link and we don't have the -l
flag.
this should print an errno error message, but does not right now.
This function wil take a directory name as argument and do pretty much the same as the top level 'ls'. When the -R
flag is present, it will call itself when it finds a directory in the directory.
with -R
enabled, we should not call ourselves for .
and ..
! this will loop.
This function will take 't_file_info *list_start', and print the information for all files in the format defined by the options.
default is 1 column, just the name, (same as ls -1
), no hidden files
-a enables display of hidden files
-l is for long format with much more detailed info.
right now we can only print predefined messages.
But in some cases we should really use errno
to determine the message to print.
We should adapt the print function so I either takes errno as an optional argument, or simply always takes an errno as argument.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.