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:
John Scipione
2014-06-29 16:18:08 -04:00
parent 0474722732
commit 9c1ca606f0
@@ -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.
*
* Authors:
* Jeremy Friesner
* John Scipione, [email protected]
*/
@@ -266,18 +267,17 @@ KeyCommandMap::MessageReceived(BMessage* message)
&& message.FindMessage("act", &actuatorMessage) == B_OK
&& message.FindMessage("modtester", &testerMessage)
== B_OK) {
// Leave handling of add-ons shortcuts to Tracker
BString command;
if (message.FindString("command", &command) == B_OK) {
BStringList paths;
BPathFinder::FindPaths(
B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker/",
B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker",
paths);
bool foundAddOn = false;
for (int32 i = 0; i < paths.CountStrings(); i++) {
if (command.FindFirst(paths.StringAt(i))
!= B_ERROR) {
int32 count = paths.CountStrings();
for (int32 i = 0; i < count; i++) {
if (command.FindFirst(paths.StringAt(i)) == 0) {
foundAddOn = true;
break;
}