Skip to content

Commit a1f4989

Browse files
committed
Haiku: Fix open path(s) reporting
We previously only returned the file names, not the full paths.
1 parent bfbb3b1 commit a1f4989

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/nfd_haiku.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ DialogHandler::MessageReceived(BMessage *msg)
130130
msg->GetInfo("refs", NULL, &mResponseData.open.count);
131131
mResponseData.open.refs = new entry_ref[mResponseData.open.count];
132132
for (int32 i = 0; i < mResponseData.open.count; i++) {
133-
entry_ref ref;
134-
msg->FindRef("refs", i, mResponseData.open.refs + i);
133+
msg->FindRef("refs", i, &mResponseData.open.refs[i]);
135134
}
136135
break;
137136
}
@@ -211,11 +210,12 @@ nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList,
211210
NFDi_SetError("Got invalid count of refs back");
212211
return NFD_ERROR;
213212
}
214-
215-
size_t length = NFDi_UTF8_Strlen((nfdchar_t *)data.open.refs[0].name) + 1;
213+
214+
BPath path(&data.open.refs[0]);
215+
size_t length = NFDi_UTF8_Strlen((nfdchar_t *)path.Path()) + 1;
216216

217217
*outPath = (nfdchar_t *)NFDi_Malloc(length);
218-
NFDi_SafeStrncpy(*outPath, data.open.refs[0].name, length);
218+
NFDi_SafeStrncpy(*outPath, path.Path(), length);
219219

220220
if (filter)
221221
delete filter;
@@ -279,8 +279,10 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
279279
return NFD_CANCEL;
280280
case kOpenResponse: {
281281
size_t total_length = 0;
282+
BPath paths[data.open.count];
282283
for (int i = 0; i < data.open.count; i++) {
283-
total_length += NFDi_UTF8_Strlen((nfdchar_t *)data.open.refs[i].name) + 1;
284+
paths[i] = BPath(&data.open.refs[i]);
285+
total_length += NFDi_UTF8_Strlen((nfdchar_t *)paths[i].Path()) + 1;
284286
}
285287

286288
outPaths->indices = (size_t *)NFDi_Malloc(sizeof(size_t) * data.open.count);
@@ -289,8 +291,8 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
289291

290292
nfdchar_t *buflocation = outPaths->buf;
291293
for (int i = 0; i < data.open.count; i++) {
292-
size_t length = NFDi_UTF8_Strlen((nfdchar_t *)data.open.refs[i].name) + 1;
293-
NFDi_SafeStrncpy(buflocation, (nfdchar_t *)data.open.refs[i].name, length);
294+
size_t length = NFDi_UTF8_Strlen((nfdchar_t *)paths[i].Path()) + 1;
295+
NFDi_SafeStrncpy(buflocation, (nfdchar_t *)paths[i].Path(), length);
294296
outPaths->indices[i] = buflocation - outPaths->buf;
295297
buflocation += length;
296298
}

0 commit comments

Comments
 (0)