CImgIOException : failed to open file

I'm trying to make my own spritepacker by entering a directory path as a command-line argument. In this function, I've saved the directory to a std::string instance of SpritePacker(in a constructor) and initialized a path object with it. Then iterating through the directory and any jpg files are pushed into a std::vector.

The problem I'm having is if I pass the directory that the program files are in, it works fine, but if I pass in a different directory also containing jpg files, I get a CImgIOException. Is there anyone familiar with CImg who can help me out, thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
bool SpritePacker::imageFilesFound() {
   const boost::filesystem::path filepath(directory);
   bool imageFound = false;

   boost::filesystem::directory_iterator iterator(filepath);
   for(; iterator != boost::filesystem::directory_iterator(); iterator++) {
      if (iterator->path().extension().string().compare(".jpg") == 0) {
         images.push_back(cimg_library::CImg<unsigned char>(iterator->path().filename().c_str()));
         imageFound = true;
      }
   }

   return imageFound;
}
Nevermind, was getting the file not the path.
Topic archived. No new replies allowed.