On Thu, 4 Dec 2003, nan wrote:
Hi all.
Anyone has an idea of how to open a file without know the complete
name of it, without opening the directory (with opendir) and test each
file?
For example, I have this:
1070471736268
and the complete file name is:
1070471736268-E1=E9=ED=F3.txt
Regards and thanks for you comments.
So you want to open a file name but:
1) you don't know its full name
2) you cannot scan the directory for the file name
Sure, I know that FILENAME_MAX is the longest a file name can be. I can
just iterate through all possible combinations of strings. If I know it
starts with a 13 character string them I want to start with that string
then all strings of length 14, 15, 16, etc. For each filename generated I
would attempt to open the file.
I, personally, would never do this. I'd use an implementation defined way
of scanning the directory.
Your question is equivalent to, "I have a word written on a piece of
paper. It starts with 'pro'. Tell me what the word is but you cannot look
at the piece of paper." This is actually easier because you can use a
dictionary to filter your guesses.
--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to
vi************@whitehouse.gov