Rewrite ls (linux) in C

bibounder -  
Sugel Posted messages 4293 Registration date   Status Member Last intervention   -
Hello,
I have a project to complete, which is to recode the "ls" command found in Linux.
Okay, this topic has already been addressed in other threads, but the problem is that we are not allowed to use printf, scanf, and all the other functions that would simplify our lives.
I have absolutely no idea where to start. Thank you in advance.

4 answers

  1. fiddy Posted messages 441 Registration date   Status Contributor Last intervention   1 847
     
    Hello,

    You need to see exactly what you are allowed...
    System function (like read())? A few standard functions (like fread())?
    Etc.
    Best regards,
    --

    Google is your friend
    0
  2. sambia39 Posted messages 610 Registration date   Status Member Last intervention   50
     
    Good evening
    To begin with, "LS" is not a function but a program that we call to list a directory and which takes arguments, and if other functions are prohibited for you, then you can use write for example

    --
    All knowledge is an answer to a question.
    0
    1. fiddy Posted messages 441 Registration date   Status Contributor Last intervention   1 847
       
      Nobody said that it was a function ;-).
      Then you have to see if fwrite() or write() is allowed...
      And others too like readdir() and so on.
      0
    2. sambia39 Posted messages 610 Registration date   Status Member Last intervention   50
       
      Not wrong :-)
      but well, if it's just printf and the like that shouldn't be used, the rest is allowed.
      0
    3. fiddy Posted messages 441 Registration date   Status Contributor Last intervention   1 847
       
      It all depends on what "company" means... I'm particularly thinking of system functions.
      0
    4. sambia39 Posted messages 610 Registration date   Status Member Last intervention   50
       
      So if that's the case, let's go through the function
       int printk() 

      but be careful, this one is reserved for the system itself, the kernel, drivers, etc.
      0
    5. fiddy Posted messages 441 Registration date   Status Contributor Last intervention   1 847
       
      If system functions are allowed, then use the write() function which has the advantage of being POSIX. Hence my very first post :-))).
      0
  3. Sugel Posted messages 4293 Registration date   Status Member Last intervention   728
     
    You, you are at Epitech, you!

    Start by recoding getchar and putchar, functions that allow you to respectively get and display a character.

    Then, look towards the system APIs to list a directory.

    Finally, you will need to work with structures and linked lists...

    I'll leave you to search!

    --
    ------------------------------------------------------------------------------------
    "Fear leads to anger. Anger leads to hate. And hate... leads to suffering." - Yoda
    0
  4. Thomato87 Posted messages 117 Status Member 16
     
    At Epitech, we've already covered this topic; I think it’s more like 42 ;)
    0
    1. Sugel Posted messages 4293 Registration date   Status Member Last intervention   728
       
      possible !
      0