Skip to content

Commit 4eb4f1a

Browse files
committed
Merge pull request #598 from JLouis-B/filePicker_fixes
Win32Core::openFilePicker fixes
2 parents aa68c6d + 025a8c4 commit 4eb4f1a

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

Core/Contents/Source/PolyWinCore.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,16 +1150,35 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> ext
11501150
ofn.lpstrInitialDir=NULL;
11511151

11521152
if(allowMultiple) {
1153-
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
1154-
} else {
11551153
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_EXPLORER;
1154+
} else {
1155+
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
11561156
}
11571157

11581158
std::vector<String> retVec;
11591159

11601160
if(GetOpenFileName(&ofn)) {
11611161
if(allowMultiple) {
1162-
1162+
String path = fBuffer;
1163+
1164+
std::string buf;
1165+
for (int i = ofn.nFileOffset; i < sizeof( fBuffer ); i++)
1166+
{
1167+
if (fBuffer[i] != NULL)
1168+
buf.push_back(fBuffer[i]);
1169+
else if (fBuffer[i-1] != NULL)
1170+
{
1171+
retVec.push_back(path + "/" + buf);
1172+
buf = "";
1173+
}
1174+
else // 2 NULL characters = no more files
1175+
break;
1176+
}
1177+
if (retVec.size() == 1)
1178+
{
1179+
retVec.clear();
1180+
retVec.push_back(path); // If only 1 file selected, path is the full path of the file
1181+
}
11631182
} else {
11641183
retVec.push_back(String(fBuffer));
11651184
}

0 commit comments

Comments
 (0)