Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: ChaosLord 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??
-
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.