c++ - tinyxml load fails after using GetOpenFileName to retrieve xml filename -
i using tinyxml 1 before implemented function getopenfilename in code, know load works whenever give relative path or absolute path.
i don't understand why doesn't work whenever function getopenfilename executes first. tried few times test , every time executed function, regardless of whether used filepath gave me or not, tinyxml still wouldn't find xml.
std::string tutname = gettutorialfilename(); if(tutname != "") { std::cout << "before replacing: " << tutname << std::endl; boost::replace_all(tutname, "\\", "/"); bool loadtutorial = tutorial->loadtutorialsteps(tutname); if(loadtutorial) { std::cout << "success!" << std::endl; } else { std::cout << "failed: " << tutname << "to load" << std::endl; } }
the function gettutorialfilename, uses getopenfilename:
std::string gettutorialfilename() { openfilename ofn; // common dialog box structure char szfile[260]; // buffer file name hwnd hwnd; // owner window handle hf; // file handle // initialize openfilename zeromemory(&ofn, sizeof(ofn)); ofn.lstructsize = sizeof(ofn); ofn.hwndowner = hwnd; ofn.lpstrfile = szfile; // set lpstrfile[0] '\0' getopenfilename not // use contents of szfile initialize itself. ofn.lpstrfile[0] = '\0'; ofn.nmaxfile = sizeof(szfile); ofn.lpstrfilter = "xml\0*.xml*\0all\0*.*\0"; ofn.nfilterindex = 1; ofn.lpstrfiletitle = null; ofn.nmaxfiletitle = 0; ofn.lpstrinitialdir = null; ofn.flags = ofn_pathmustexist | ofn_filemustexist; // display open dialog box. if (getopenfilename(&ofn)==true) { hf = createfile(ofn.lpstrfile, generic_read, 0, (lpsecurity_attributes) null, open_existing, file_attribute_normal, (handle) null); std::string tutorialfilename(szfile); return tutorialfilename; } return "";
}
i know finds tutorialfilename no spaces i've ran debugger on that, still can't understand why tinyxml fails load.
i figured out issue. tinyxml outputting error 13 - permission denied due createfile blocking access file. deleted function because don't need it.
Comments
Post a Comment