Code

A

arun

Sabari said:
Hi all,
May i want c coding for ls command did any one help?.
Thanks in advanced.

Please read the manual pages for the opendir() and readdir().
You can use these functions for a simple implementation of the ls
command.
 
V

Vladimir Oka

Sabari said:
May i want c coding for ls command did any one help?.

I asume you mean:

"If I wanted to implement the (*nix) `ls` command,
can anyone help?"

I'd suggest you look into any of the numerous Linux distributions
(*BSD, and Open Solaris may help as well). They should all provide the
source for theirs.
 
C

Chris Hills

Zero said:
Could you be more precise?

He was. He wants the source code for the unix ls command. It is probably
part of Linux or Free BSD

In any event he is inthe wrong NG
 
R

Robert Gamble

arun said:
Please read the manual pages for the opendir() and readdir().
You can use these functions for a simple implementation of the ls
command.

opendir and readdir are not Standard C functions and are thus off-topic
here. Since most implementations of ls (including are those conforming
to POSIX) perform significantly more operations than can be
accomplished with these two functions and the OP didn't ask about
implementing a specific part of the command I doubt your suggestion
would be of much use, even if it was on-topic.

Robert Gamble
 
A

arun

Robert said:
opendir and readdir are not Standard C functions and are thus off-topic
here. Since most implementations of ls (including are those conforming
to POSIX) perform significantly more operations than can be
accomplished with these two functions and the OP didn't ask about
implementing a specific part of the command I doubt your suggestion
would be of much use, even if it was on-topic.

Robert Gamble

I dont think we can use only standard C functions for implementing a
command like ls.
And i dont know whether there is any standard C function for reading
directories and inode details. I thought a simple implementation of ls
can be using opendir() and readdir(). Of course they are not going to
give you all the informations provided by ls. But still you can get the
directory entries and you can use functions like stat to get more
details.
But this of course is not the real implementation for ls.
I dont know the purpose of the code sabari asked for. If you want to
get the real thing you can read the ls source code that comes with any
free unix distro. I had read the source code that came with redhat
linux. It was having about 4000 lines of code.

Regards,
arun..
 
R

Robert Gamble

arun said:
I dont think we can use only standard C functions for implementing a
command like ls.

No, you can't, which is why it is off-topic here. comp.unix.programmer
would be a much better place to discuss this further.

Robert Gamble
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,964
Members
47,511
Latest member
svareza

Latest Threads

Top