   Deleting a directory of files
  I really hate messing with this stuff. And I rarely need to. But I need to clear out the runtime folder of my game, and there's no other way around it. I thought about keeping a list of all saved game files, then simply deleting files in the list, one at a time. But this wouldn't work at all if the game crashed, or some other error or problem occurs. Some files could get stuck in the runtime folder forever.Just wondering if someone could steer me into the direction of a safe, built-in C/C++ class or function set to do this. Let me know if any more information is needed.Thanks a lot.   
Quote:Original post by KestJust wondering if someone could steer me into the direction of a safe, built-in C/C++ class or function set to do this. Let me know if any more information is needed.The closest thing to a safe, portable, and sort of built-in solution I can think of is boost::filesystem. It's a little less trivial to integrate into a project than other boost stuff, but it's worth the effort. boost::filesystem includes functions and classes that make it very easy to iterate through the contents of a directory, which sounds like what you want.   ;  Unfortunately there isn't a built in way to do this and any third party library you may use will also not work if your game crashes (unless it is your own file-deleting code that is causing the crash, obviously).If you are using Windows, you could use FindFirstFile etc to scan the directory and identify any unwanted save files if you have lost the list. Perhaps you could implement a flag that is cleared in a file on startup and set on normal shut down and, if when the game is run next time this flag is not set (indicating a previous crash), rescan the directory then and delete any unwanted files.   