I'm writing a C++ program that must run on both Mac and Windows. The code itself is portable enough, but I'm having trouble figuring out how to handle file paths. My program uses two directories/folders: one for input, one for output. How might one handle this?
The real rub is the Mac OS creation of a "package" for its executables. I can't see how to get around this without the use of absolute file names.
I'd prefer relative pathnames. I guess if I take the absolute pathname and edit it to form the paths to my other directories, that would work. I'll have to allow for the fact that Mac OS and Windows use different folder delimiters ("/" vs. "\") and there may be some other snags in there.
It would be nice if I could just use "../other-directory-name" but even this will require a conditional compile (for the delimiter). No really clean solution, is there?
argv[0] is only the program name as was given to the shell (e.g. "program", "..\program", "\program"). The working directory need not, and generally will not, be included.
Windows accepts forward slashes. It's kind of puzzling that they're accepted at the API level but not at the UI level, isn't it?