J
jacob navia
Eric Sosman said:What if the directories have multiple entries for the
same file, in the manner of those Windows versions that
support both "long" and "DOS" file names? If you return
all the entries you enumerate many files twice. If you
return only the "DOS" names you deprive the user of the
benefits of the "long" names. If you suppress the "DOS"
names of files that also have "long" names, you exasperate
the users who need to get at the "DOS" names. No one
strategy suits all scenarios, so suddenly you've got to
expand the API somehow.
I explained the solution in the tutorial article where I wrote
a function to scan files. (Section 1.33)
The solution is to use function pointers and let the user
figure out what he/she wants.
Easy isn't it?
No API. You just call a user defined function.
[snip]
The only language I've personally used that tried to
invent a directory abstraction wide enough to cover all these
cases (and more) was Common LISP -- and believe me, the
edifice was more impressive for its size and complexity than
for its utility. A lot of hard work by very smart people
produced something only a certified genius could use in any
but the simplest settings. Go look it up; it's eye-opening.
It is the wrong alley.
The solution is to use function pointers.
That is VERY EASY in C. It is one of the most powerful features
of C. The way you pass function tokens carrying an incredible
amount of context with just a few machine instructions.
There is NO BEST API, it is better that each usage involves
writing a small function that does exactly what you want.
www.cs.virginia.ed/~lcc-win32