Re: Directory reading



mattia <gervaz@xxxxxxxxx> writes:
On Thu, 04 Dec 2008 21:38:11 +0000, Antoninus Twink wrote:

On 4 Dec 2008 at 20:24, vippstar@xxxxxxxxx wrote:
On Dec 4, 10:19 pm, mattia <ger...@xxxxxxxxx> wrote:
Hi everyone, can you suggest me an efficient way to list all the files
in a directory (under linux)?

Off-topic here. Try asking in <comp.unix.programmer>.

"VIP Star" is a troll who seeks to disrupt the newsgroup, best ignored.

Check out readdir(3), and post again if you have any problems.

Ok, done, found what I was looking for at advancedlinuxprogramming.com,
I'll not consider vipstar sugestions again ;-)

That's a bad idea. "Antoninus Twink" is very likelyi correct that
readdir() is the solution to your problem, but he's quite simply lying
about vippstar. "Antoninus Twink" is a troll who deliberately tries
to disrupt this newsgroup, mostly by encouraging off-topic discussions
that should take place in other newsgroups.

Here are the facts. The readdir function is not defined, or even
mentioned, by the standard that defines the C programming language.
In fact, there's no mention of directories at all. (It's been argued
that there should be, and there have been proposals to add directory
support in future revisions of the standard, but that hasn't happened
yet -- and defining directory support in a way that's compatible with
all the current and potential hosted systems on which C is supported
is decidedly non-trivial.)

The readdir function is defined by the POSIX standard, which means
(approximately) that it's specific to Unix and Unix-like systems. On
MS Windows, for example, you'd probably want to use some different
function to read a directory.

Here in comp.lang.c, we generally try to discuss the C programming
langauge as defined by the C language standard (past and current
versions). Questions about Unix-specific programming, such as how to
use readdir(), are better asked in comp.unix.programmer, which is full
of experts on the topic. Many of us here know about Unix programming
as well, but everyone makes mistakes, and any Unix-specific
information posted here will receive much less checking by experts
than similar information posted in comp.unix.programmer.

Similarly, questions about Windows programming should be asked in
comp.os.ms-windows.programmer.win32 or a similar group.

There was nothing seriously wrong with your original question; not
everyone can be expected to know that the C language doesn't actually
support directory operations. But vippstar's response was entirely
appropriate; since you're using Linux, comp.unix.programmer is the
right place to ask.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: [Lit.] Buffer overruns
    ... > And of course the most direct expression of your, at best, weak support ... Good PLs make good programming easier. ... This is an integrity feature and also ... built-in extension to Standard C. ...
    (sci.crypt)
  • Re: Programming in standard c
    ... You can't do *anything* in just standard C. ... Then why do you bother with this newsgroup? ... dozen or more platforms that we have had to support, still support, or ... the regulars are unable to put any coherent argumentation. ...
    (comp.lang.c)
  • Re: (OT) C++ forums
    ... The group is solely to discuss the C++ standard. ... one asks general programming questions there which deviate even slightly ... see if there is newsgroup specifically for learning how to program ... do examples and post specific questions on mailing lists or ...
    (Ubuntu)
  • Re: (OT) C++ forums
    ... The group is solely to discuss the C++ standard. ... one asks general programming questions there which deviate even slightly ... see if there is newsgroup specifically for learning how to program ... The other choice is to try a linux newsgroup where spectrum of questions ...
    (Ubuntu)
  • Re: how do i clear a screen?
    ... >>C that is not the dialect being discussed here. ... >>as discussed in this newsgroup, ... a freestanding implementation need not support the standard ... The standard library is for hosted implementations. ...
    (alt.comp.lang.learn.c-cpp)