Welcome, Guest. Please login or register.

Author Topic: Dir scanning: Which method is best?  (Read 1054 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ChaosLordTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Dir scanning: Which method is best?
« on: October 13, 2006, 01:55:43 PM »
Programming Question:
What is the best techinique to traverse a directory?

1. UNIX opendir() readdir()
2. SASC dnext() dfind()
3. AmigaOS Examine() ExNext()
4. AmigaOS ExAll()

Aargh!  Decisions decisions!

I need to traverse some directories at high speed.
At first I was going to use the UNIX way of opendir() readdir() based on
the assumption that every C compiler in the universe has those
functions.  BUT I can't figure out how to tell if it has returned a
FILEname or a DIRname?  My old SASC manual seems to be missing that info.
Or maybe it just isn't possible under unix?

Then I noticed some old code that uses dnext() and dfind().  Very nice
and simple and great!  BUT the manual says these only exist in SASC!
ARGH!  I am trying to write multiplatform-friendly code!

So then I figured I could use AmigaOS routines.  They should be the
fastest and smoothest under AmigaOS but I will have to completely rewrite
them when I port the game to SDL. :(((

AND even if I use AmigaOS way of doing things... which technique should I
use?  Examine() + ExNext() ?    Or ExAll() ?  Auugh!

How do I decide??
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Dir scanning: Which method is best?
« Reply #1 on: October 13, 2006, 02:03:54 PM »
Why don't you use the AmigaOS functions, wrapped behind your own minimalist set of functions that do the job you need. Keep the implementation of them together in one file.

When you come to port your stuff, you can just reimplement that subset to use whatever is appropriate for the platform you are building the code for.
int p; // A