Skip to content

simple-lemon/arc-02-my_ls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

arc-02-my_ls

My Ls

Remember to git add && git commit && git push each exercise!

We will execute your function with our test(s), please DO NOT PROVIDE ANY TEST(S) in your file

For each exercise, you will have to create a folder and in this folder, you will have additional files that contain your work. Folder names are provided at the beginning of each exercise under submit directory and specific file names for each exercise are also provided at the beginning of each exercise under submit file(s).


My Ls
Submit directory .
Submit files Makefile - *.c - *.h

Description

SPECIFICATIONS

Write a programm called my_ls. Following the specifications of this man page.

NAME

my_ls -- list directory contents

SYNOPSIS

my_ls [-at] [file ...]

DESCRIPTION

For each operand that names a file of a type other than directory, my_ls displays its name as well as any requested, associated information. For each operand that names a file of type directory, my_ls displays the names of files contained within that directory, as well as any requested, associated information.

If no operands are given, the contents of the current directory are displayed. If more than one operand is given, non-directory operands are displayed first; directory and non-directory operands are sorted separately and in lexicographical order.

The following options are available:

  • -a Include directory entries whose names begin with a dot (.).
  • -t Sort by time modified (most recently modified first) before sorting the operands by lexicographical order.

Requirements

  • Your code must be compiled with the flags -Wall -Wextra -Werror.

Hint(s)

  • Watch out for memory leaks !
  • You can test your code against memory errors by compiling with the debugging flags -g3 -fsanitize=address
  • Global variables are strictly FORBIDDEN
  • tv_sec AND tv_nsec are used for the -t options ;-)
  • st_mtime is not what you want to use. You want to use st_mtim

Technical information

  1. you must create a Makefile, and the ouput is the command itself
  2. You can use:
  • malloc(3)
  • free(3)
  • printf(3)
  • write(2)
  • stat(2)
  • lstat(2)
  • opendir(2)
  • closedir(2)
  • readdir(2)
  1. You can NOT use:
  • Any functions / syscalls which does not appear in the previous list
  • Yes, it includes exit
  • Multiline macros are forbidden
  • Include another .c is forbidden
  • Macros with logic (while/if/variables/...) are forbidden
  1. Your output needs to be respecting the "sorting" criteria and in one column. It will be compared with: ls -1.
$>./my_ls > my_ls.output
$>ls -1 > ls.output
$>diff my_ls.output ls.output
$>

Tips

Check /dev What is the difference between stat and lstat?

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published