Tracker: Use BPathFinder to find add-ons
This commit is contained in:
parent
6cf062b93d
commit
1f17f750db
@ -38,11 +38,14 @@ All rights reserved.
|
|||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <PathFinder.h>
|
||||||
#include <PathMonitor.h>
|
#include <PathMonitor.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <StringList.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
#include <VolumeRoster.h>
|
#include <VolumeRoster.h>
|
||||||
|
|
||||||
@ -126,20 +129,11 @@ FindElement(struct AddonShortcut* item, void* castToOther)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LoadAddOnDir(directory_which dirName, BDeskWindow* window,
|
LoadAddOnDir(BDirectory directory, BDeskWindow* window,
|
||||||
LockingList<AddonShortcut>* list)
|
LockingList<AddonShortcut>* list)
|
||||||
{
|
{
|
||||||
BPath path;
|
|
||||||
if (find_directory(dirName, &path) == B_OK) {
|
|
||||||
path.Append("Tracker");
|
|
||||||
|
|
||||||
BDirectory dir;
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
|
while (directory.GetNextEntry(&entry) == B_OK) {
|
||||||
if (dir.SetTo(path.Path()) != B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (dir.GetNextEntry(&entry) == B_OK) {
|
|
||||||
Model* model = new Model(&entry);
|
Model* model = new Model(&entry);
|
||||||
if (model->InitCheck() == B_OK && model->IsSymLink()) {
|
if (model->InitCheck() == B_OK && model->IsSymLink()) {
|
||||||
// resolve symlinks
|
// resolve symlinks
|
||||||
@ -176,12 +170,11 @@ LoadAddOnDir(directory_which dirName, BDeskWindow* window,
|
|||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
BNode node(path.Path());
|
BNode node(&directory, NULL);
|
||||||
node_ref nodeRef;
|
node_ref nodeRef;
|
||||||
node.GetNodeRef(&nodeRef);
|
node.GetNodeRef(&nodeRef);
|
||||||
|
|
||||||
TTracker::WatchNode(&nodeRef, B_WATCH_DIRECTORY, window);
|
TTracker::WatchNode(&nodeRef, B_WATCH_DIRECTORY, window);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -279,10 +272,13 @@ BDeskWindow::InitAddonsList(bool update)
|
|||||||
fAddonsList->MakeEmpty(true);
|
fAddonsList->MakeEmpty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadAddOnDir(B_USER_NONPACKAGED_ADDONS_DIRECTORY, this, fAddonsList);
|
BStringList addOnPaths;
|
||||||
LoadAddOnDir(B_USER_ADDONS_DIRECTORY, this, fAddonsList);
|
BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker/",
|
||||||
LoadAddOnDir(B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, this, fAddonsList);
|
addOnPaths);
|
||||||
LoadAddOnDir(B_SYSTEM_ADDONS_DIRECTORY, this, fAddonsList);
|
for (int32 i = 0; i < addOnPaths.CountStrings(); i++) {
|
||||||
|
LoadAddOnDir(BDirectory(addOnPaths.StringAt(i)), this,
|
||||||
|
fAddonsList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,31 +320,18 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
|
|||||||
if (message.FindString("command", &command) != B_OK)
|
if (message.FindString("command", &command) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BPath path;
|
|
||||||
bool isInAddons = false;
|
bool isInAddons = false;
|
||||||
if (find_directory(B_SYSTEM_ADDONS_DIRECTORY, &path)
|
|
||||||
== B_OK) {
|
BStringList addOnPaths;
|
||||||
path.Append("Tracker/");
|
BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY,
|
||||||
isInAddons = command.FindFirst(path.Path()) == 0;
|
"Tracker/", addOnPaths);
|
||||||
|
for (int32 i = 0; i < addOnPaths.CountStrings(); i++) {
|
||||||
|
if (command.FindFirst(addOnPaths.StringAt(i)) == 0) {
|
||||||
|
isInAddons = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!isInAddons
|
|
||||||
&& (find_directory(B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
|
|
||||||
&path) == B_OK)) {
|
|
||||||
path.Append("Tracker/");
|
|
||||||
isInAddons = command.FindFirst(path.Path()) == 0;
|
|
||||||
}
|
|
||||||
if (!isInAddons
|
|
||||||
&& (find_directory(B_USER_ADDONS_DIRECTORY, &path)
|
|
||||||
== B_OK)) {
|
|
||||||
path.Append("Tracker/");
|
|
||||||
isInAddons = command.FindFirst(path.Path()) == 0;
|
|
||||||
}
|
|
||||||
if (!isInAddons
|
|
||||||
&& (find_directory(B_USER_NONPACKAGED_ADDONS_DIRECTORY,
|
|
||||||
&path) == B_OK)) {
|
|
||||||
path.Append("Tracker/");
|
|
||||||
isInAddons = command.FindFirst(path.Path()) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isInAddons)
|
if (!isInAddons)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user