I have a C++ application that I am developing to scan an image and return coordinates, the whole application works as expected except for this last problem that I can't seem to figure out. a user uploads images to a folder, and then the images get run one at a time to the application in a queue. well the problem is, that we have thousands of users with many folders, and a good amount of these users upload folder/files with a space (ex: " "), in the folder/file name.
When the application runs it crashes, I have narrowed it down to the fact that CImg does not like spaces in the path.
Every time it runs on my local machine with a space in the path I get the following error, which doesn't seem to say much.
Unhandled exception at 0x00BE05F7 in jpeg-info.exe: 0xC00000FD: Stack overflow >(parameters: 0x00000000, 0x00242000).
[CImg] * CImgIOException * [instance(0,0,0,0,00000000,non-shared)] CImg::load(): Failed to open file 'J:\uploads\41039\test name'
[CImg] * CImgIOException * cimg::fopen(): Failed to open file 'J:\uploads\41039\test name' with mode 'rb'.
the line of code it fails on is here.
const char* imagePath = filename.c_str();
CImg<unsigned char> loadImage(imagePath);
I just need to figure out a way to pass a path to CImg with spaces in the string and it not break.
Sidenote: I do have the boost filesystem installed if that makes it any easier to figure out this solution.
EDIT:
I was getting the filename two different ways with not luck on fixing this issue..
original way: (passing const char directly)
const char* filename = cimg_option("-i", "path/to/file/jpeg.jpg", "input jpeg path");
new way: (grabbing path and using boost to format it properly)
const char* getInput = cimg_option("-i", "path/to/file/jpeg.jpg", "input jpeg path");
std::string filename = boost::filesystem::absolute(getInput).string();