R
Robbie Hatley
Here's a bug I found in a program of mine, after much
exasperation trying to find out why this wasn't working.
You all might find it educational and/or entertaining.
I had this line of code:
rhdir::LoadFileList(RawFiles, "qgv??-raw.txt");
Basically, it looks for files in the current directory
named "qgv??-raw.txt" (where the question marks are
being used in the context of wildcard characters),
and loads the names of all such files into a
std::list<std::string> object named "RawFiles".
Seems very simple.
And yet, although I had a bunch of files named:
qgv17-raw.txt
qgv32-raw.txt
qgv88-raw.txt
none of them were getting into the list. What went
wrong?
You ain't gonna believe this....
The function LoadFileList() was actually looking for
a file named "qgv~raw.txt", and since there was no
such file, the "RawFiles" list remained empty.
Why?
The answer is: the character sequence ??- is NOT
three characters! It's ONE character, a tilde ~ .
It's one of those blasted "triglyph" thingies left
over from the days when certain characters weren't
actually on keyboards and had to be "faked".
So I backslashed the question marks:
rhdir::LoadFileList(RawFiles, "qgv\?\?-raw.txt");
and the program worked fine. Live and learn.
exasperation trying to find out why this wasn't working.
You all might find it educational and/or entertaining.
I had this line of code:
rhdir::LoadFileList(RawFiles, "qgv??-raw.txt");
Basically, it looks for files in the current directory
named "qgv??-raw.txt" (where the question marks are
being used in the context of wildcard characters),
and loads the names of all such files into a
std::list<std::string> object named "RawFiles".
Seems very simple.
And yet, although I had a bunch of files named:
qgv17-raw.txt
qgv32-raw.txt
qgv88-raw.txt
none of them were getting into the list. What went
wrong?
You ain't gonna believe this....
The function LoadFileList() was actually looking for
a file named "qgv~raw.txt", and since there was no
such file, the "RawFiles" list remained empty.
Why?
The answer is: the character sequence ??- is NOT
three characters! It's ONE character, a tilde ~ .
It's one of those blasted "triglyph" thingies left
over from the days when certain characters weren't
actually on keyboards and had to be "faked".
So I backslashed the question marks:
rhdir::LoadFileList(RawFiles, "qgv\?\?-raw.txt");
and the program worked fine. Live and learn.