Finding files with C

  • Thread starter Thread starter Marcb
  • Start date Start date
  • Replies Replies 3
  • Views Views 4287

Marcb

New member
AmiBayer
Joined
Apr 15, 2008
Posts
110
Country
Australia
Region
Sydney
Hi,

I was wondering what the best way is of finding and compiling a list of files using C?

What I'd like to do is scan through a drive or drives for files with a ".slave" extension in a relatively quick time and store them in a dynamic list...

A couple of years ago I wrote a small program to do this but it took a few hours so I'm guessing that I did it the wrong way....:help:

All help will be appreciated!

Cheers,
Marc
 
Crikey, in C? Not sure. A very small AmigaDOS script could do the job, which you could pipe into a C program quite easily.

In C alone, there are likely a couple of stdio library functions which would accomplish the job. My C is very rusty, so I'm really not being very helpful here.

I'll just get my coat....:whistle:
 
I had to do just this as part of my computer science degree... Let me see if I can find it.
 
Hi,

iam very rusty with c and never programmed on an Amiga :lol: but it should work with opendir and readdir.

With opendir you get a pointer to the specified directory and you can loop with readdir throught the dirctory entries. You will have to distinguish between files and directories. If its a file compare the last characters to ".slave". If its a directory you will need recursion.
 
Back
Top Bottom