Loading specific files from arbitrary directories?
Posted
by
Haydn V. Harach
on Stack Overflow
See other posts from Stack Overflow
or by Haydn V. Harach
Published on 2014-08-21T23:00:15Z
Indexed on
2014/08/22
10:20 UTC
Read the original article
Hit count: 174
I want to load foo.txt
. foo.txt
might exist in the data/bar/
directory, or it might exist in the data/New Folder/
directory. There might be a different foo.txt
in both of these directories, in which case I would want to either load one and ignore the other according to some order that I've sorted the directories by (perhaps manually, perhaps by date of creation), or else load them both and combine the results somehow. The latter (combining the results of both/all foo.txt
files) is circumstantial and beyond the scope of this question, but something I want to be able to do in the future.
I'm using SDL and boost::filesystem
. I want to keep my list of dependencies as small as possible, and as cross-platform as possible.
I'm guessing that my best bet would be to get a list of every directory (within the data/
folder), sort/filter this list, then when I go to load foo.txt
, I search for it in each potential directory? This sounds like it would be very inefficient, if I have dozens of potential directories to search through every time.
What's the best way to go about accomplishing this?
Bonus: What if I want some of the directories to be archives? ie. considering both data/foo/
and data/bar.zip
to both be valid, and pull foobar.txt
from either one without caring.
© Stack Overflow or respective owner