Skip to content

Commit 025a8c4

Browse files
committed
fix for multiple files selection
1 parent 49eb36b commit 025a8c4

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Core/Contents/Include/PolyWinCore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939

4040
#include <vector>
41-
#include <sstream>
4241

4342
#ifndef VK_0
4443
#define VK_0 '0'

Core/Contents/Source/PolyWinCore.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,11 +1147,26 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> ext
11471147

11481148
if(GetOpenFileName(&ofn)) {
11491149
if(allowMultiple) {
1150+
String path = fBuffer;
1151+
11501152
std::string buf;
1151-
std::stringstream filesList(String(fBuffer).getSTLString());
1152-
1153-
while (filesList >> buf)
1154-
retVec.push_back(buf);
1153+
for (int i = ofn.nFileOffset; i < sizeof( fBuffer ); i++)
1154+
{
1155+
if (fBuffer[i] != NULL)
1156+
buf.push_back(fBuffer[i]);
1157+
else if (fBuffer[i-1] != NULL)
1158+
{
1159+
retVec.push_back(path + "/" + buf);
1160+
buf = "";
1161+
}
1162+
else // 2 NULL characters = no more files
1163+
break;
1164+
}
1165+
if (retVec.size() == 1)
1166+
{
1167+
retVec.clear();
1168+
retVec.push_back(path); // If only 1 file selected, path is the full path of the file
1169+
}
11551170
} else {
11561171
retVec.push_back(String(fBuffer));
11571172
}

0 commit comments

Comments
 (0)