OK it’s not the name of the xml path string either forget everything I said above!
I am making a new guess on what the bug is…
after trying many variations of the saving string and tested the paths in another pc program and made sure that they worked…
I realised… That I Use the
ofBeginSaveScreenAsPDF(saveFileResult.filePath+".pdf", true);
ofSystemSaveDialog(“Weekly_”+ofGetTimestampString() + “” , “Save your file”);
in OSx it gives a path. on windows 8 it doesn’t.
and furthermore
After selecting a path it brakes the /…/data/ directory in OF.
OF doesn’t point to that path any more
thus not allowing to load images and save xml after calling the saveFileResult.filepath
any ideas on how to fix this?
///EDIT
OK I am 100% sure that this is the problem, I’ve tested the code without calling the
ofSystemSaveDialog function in the PC version and the XML saves and all the images load and in general the OF remembers where the OF data folder is.
So the problem lies in this Code inside
ofSystemUtils.cpp
inside our ofSystemSaveDialog function
#ifdef TARGET_WIN32
wchar_t fileName[MAX_PATH] = L"";
char * extension;
OPENFILENAMEW ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
HWND hwnd = WindowFromDC(wglGetCurrentDC());
ofn.hwndOwner = hwnd;
ofn.hInstance = GetModuleHandle(0);
ofn.nMaxFileTitle = 31;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = L"All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = L""; // we could do .rxml here?
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
ofn.lpstrTitle = L"Select Output File";
if (GetSaveFileNameW(&ofn)){
results.filePath = convertWideToNarrow(fileName);
}
#endif
First of all I’ve noticed that we don’t pass the defaultName string that has the initial path that we give in
example :
ofSystemSaveDialog(“mypath/blabla/file”);
in mac version we grab that string in the PC version we start from the directory that the program runs and when we select a different directory this brakes the data path that OF has in its memory (I put it in simple terms)
/////how do I know this is the problem:
at the begining of my program I call
**cout<<getCurrentWorkingDirectory();
**
This returns Path::current(); from Path.h
that string is the directory of where the program looks for files
When I call the ofSystemSaveDialog()
on the mac getCurrentWorkingDirectory(); still returns the original directory so when I try to load an image after using ofSystemSaveDialog it works.
(but on the pc version)
then ** cout<<getCurrentWorkingDirectory();** returns the place where I saved the file
for example c:\users\desktop
so the pc it later on the APP doesn’t save or load anything from the data directory and it returns the. Can’t load image “data/blabla/imag.png”
I tried copying getCurrentWorkingDirectory() to a string
and then pass it using **ofToDataPath(string, true/false);
**
but no luck yet
////
(anyway sorry about all the rumbling)
Question:
**How can we set the data path back to normal /…/data/ after we have finished saving to our location?
**
basically how can we set
Path::current(); from POCO back to the normal directory that we can grab from getCurrentWorkingDirectory() before using the ofSystemSaveDialog()?
something like: ofSetDataPathRoot(DEFAULT_DIRECTORY);
/////////////////////////////////////////