GUI: fix file path corruption on sys file picker
This commit is contained in:
parent
ac286fc8d1
commit
7bb0743598
|
|
@ -8,6 +8,7 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, c
|
||||||
if (opened) return false;
|
if (opened) return false;
|
||||||
saving=false;
|
saving=false;
|
||||||
curPath=path;
|
curPath=path;
|
||||||
|
logD("opening load file dialog with curPath %s",curPath);
|
||||||
if (sysDialog) {
|
if (sysDialog) {
|
||||||
dialogO=new pfd::open_file(header,path,filter);
|
dialogO=new pfd::open_file(header,path,filter);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -22,6 +23,7 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, c
|
||||||
if (opened) return false;
|
if (opened) return false;
|
||||||
saving=true;
|
saving=true;
|
||||||
curPath=path;
|
curPath=path;
|
||||||
|
logD("opening save file dialog with curPath %s",curPath);
|
||||||
if (sysDialog) {
|
if (sysDialog) {
|
||||||
dialogS=new pfd::save_file(header,path,filter);
|
dialogS=new pfd::save_file(header,path,filter);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -65,6 +67,8 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
|
||||||
if (dialogS!=NULL) {
|
if (dialogS!=NULL) {
|
||||||
if (dialogS->ready(0)) {
|
if (dialogS->ready(0)) {
|
||||||
fileName=dialogS->result();
|
fileName=dialogS->result();
|
||||||
|
size_t dsPos=fileName.rfind(DIR_SEPARATOR);
|
||||||
|
if (dsPos!=String::npos) curPath=fileName.substr(0,dsPos);
|
||||||
logD("returning %s",fileName.c_str());
|
logD("returning %s",fileName.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +81,8 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
|
||||||
logD("returning nothing");
|
logD("returning nothing");
|
||||||
} else {
|
} else {
|
||||||
fileName=dialogO->result()[0];
|
fileName=dialogO->result()[0];
|
||||||
|
size_t dsPos=fileName.rfind(DIR_SEPARATOR);
|
||||||
|
if (dsPos!=String::npos) curPath=fileName.substr(0,dsPos);
|
||||||
logD("returning %s",fileName.c_str());
|
logD("returning %s",fileName.c_str());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -91,8 +97,15 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
|
||||||
|
|
||||||
String FurnaceGUIFileDialog::getPath() {
|
String FurnaceGUIFileDialog::getPath() {
|
||||||
if (sysDialog) {
|
if (sysDialog) {
|
||||||
|
if (curPath.size()>0) {
|
||||||
|
if (curPath[curPath.size()-1]==DIR_SEPARATOR) {
|
||||||
|
curPath=curPath.substr(0,curPath.size()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logD("curPath: %s",curPath);
|
||||||
return curPath;
|
return curPath;
|
||||||
} else {
|
} else {
|
||||||
|
logD("curPath: %s",ImGuiFileDialog::Instance()->GetCurrentPath());
|
||||||
return ImGuiFileDialog::Instance()->GetCurrentPath();
|
return ImGuiFileDialog::Instance()->GetCurrentPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue