Skip to content

Commit

Permalink
Merge pull request #598 from JLouis-B/filePicker_fixes
Browse files Browse the repository at this point in the history
Win32Core::openFilePicker fixes
  • Loading branch information
ivansafrin committed Dec 28, 2014
2 parents aa68c6d + 025a8c4 commit 4eb4f1a
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Core/Contents/Source/PolyWinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,16 +1150,35 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> ext
ofn.lpstrInitialDir=NULL;

if(allowMultiple) {
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
} else {
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_EXPLORER;
} else {
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
}

std::vector<String> retVec;

if(GetOpenFileName(&ofn)) {
if(allowMultiple) {

String path = fBuffer;

std::string buf;
for (int i = ofn.nFileOffset; i < sizeof( fBuffer ); i++)
{
if (fBuffer[i] != NULL)
buf.push_back(fBuffer[i]);
else if (fBuffer[i-1] != NULL)
{
retVec.push_back(path + "/" + buf);
buf = "";
}
else // 2 NULL characters = no more files
break;
}
if (retVec.size() == 1)
{
retVec.clear();
retVec.push_back(path); // If only 1 file selected, path is the full path of the file
}
} else {
retVec.push_back(String(fBuffer));
}
Expand Down

1 comment on commit 4eb4f1a

@fodinabor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is broken for me.. sometimes returns the path + ";" or sth else.. I'll use my version in my #564 rebase - is proven to be working..

Please sign in to comment.