Media Preflet: Use BPathFinder::FindPaths() instead of the C method.
This way we can use BStringList and get rid of the manual deallocation.
This commit is contained in:
@@ -17,10 +17,12 @@
|
|||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <PathFinder.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
|
#include <StringList.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "Midi View"
|
#define B_TRANSLATION_CONTEXT "Midi View"
|
||||||
@@ -89,17 +91,16 @@ MidiSettingsView::MessageReceived(BMessage* message)
|
|||||||
void
|
void
|
||||||
MidiSettingsView::_RetrieveSoftSynthList()
|
MidiSettingsView::_RetrieveSoftSynthList()
|
||||||
{
|
{
|
||||||
char **paths = NULL;
|
BStringList paths;
|
||||||
size_t pathCount = 0;
|
status_t status = BPathFinder::FindPaths(B_FIND_PATH_DATA_DIRECTORY,
|
||||||
status_t status = find_paths(B_FIND_PATH_DATA_DIRECTORY, "synth",
|
"synth", paths);
|
||||||
&paths, &pathCount);
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fListView->MakeEmpty();
|
fListView->MakeEmpty();
|
||||||
|
|
||||||
for (size_t i = 0; i < pathCount; i++) {
|
for (int32 i = 0; i < paths.CountStrings(); i++) {
|
||||||
BDirectory directory(paths[i]);
|
BDirectory directory(paths.StringAt(i).String());
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
if (directory.InitCheck() != B_OK)
|
if (directory.InitCheck() != B_OK)
|
||||||
continue;
|
continue;
|
||||||
@@ -115,14 +116,12 @@ MidiSettingsView::_RetrieveSoftSynthList()
|
|||||||
// TODO: For some reason this doesn't work
|
// TODO: For some reason this doesn't work
|
||||||
if (nodeInfo.GetType(mimeType) == B_OK
|
if (nodeInfo.GetType(mimeType) == B_OK
|
||||||
/*&& !strcmp(mimeType, "audio/x-soundfont")*/) {
|
/*&& !strcmp(mimeType, "audio/x-soundfont")*/) {
|
||||||
BPath fullPath = paths[i];
|
BPath fullPath = paths.StringAt(i).String();
|
||||||
fullPath.Append(entry.Name());
|
fullPath.Append(entry.Name());
|
||||||
fListView->AddItem(new BStringItem(fullPath.Path()));
|
fListView->AddItem(new BStringItem(fullPath.Path()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(paths);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user