shortcut_catcher: Small refactor to FindPaths()
Should be functionally identical. * Removed / after Tracker, thanks Axel. * BString::FindFirst() returns an index not a status_t so check that it finds the path at the start of the string (index 0). * Put paths.CountStrings() in a count variable. I wanted to clean this code up because I use it as a reference.
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1999-2009 Haiku, Inc. All rights reserved.
|
* Copyright 1999-2014 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jeremy Friesner
|
* Jeremy Friesner
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -266,18 +267,17 @@ KeyCommandMap::MessageReceived(BMessage* message)
|
|||||||
&& message.FindMessage("act", &actuatorMessage) == B_OK
|
&& message.FindMessage("act", &actuatorMessage) == B_OK
|
||||||
&& message.FindMessage("modtester", &testerMessage)
|
&& message.FindMessage("modtester", &testerMessage)
|
||||||
== B_OK) {
|
== B_OK) {
|
||||||
|
|
||||||
// Leave handling of add-ons shortcuts to Tracker
|
// Leave handling of add-ons shortcuts to Tracker
|
||||||
BString command;
|
BString command;
|
||||||
if (message.FindString("command", &command) == B_OK) {
|
if (message.FindString("command", &command) == B_OK) {
|
||||||
BStringList paths;
|
BStringList paths;
|
||||||
BPathFinder::FindPaths(
|
BPathFinder::FindPaths(
|
||||||
B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker/",
|
B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker",
|
||||||
paths);
|
paths);
|
||||||
bool foundAddOn = false;
|
bool foundAddOn = false;
|
||||||
for (int32 i = 0; i < paths.CountStrings(); i++) {
|
int32 count = paths.CountStrings();
|
||||||
if (command.FindFirst(paths.StringAt(i))
|
for (int32 i = 0; i < count; i++) {
|
||||||
!= B_ERROR) {
|
if (command.FindFirst(paths.StringAt(i)) == 0) {
|
||||||
foundAddOn = true;
|
foundAddOn = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user