From 2c2f3ab4e1b8dd6b043cb571384c25746b53e4a4 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 16 Nov 2013 22:28:36 +0100 Subject: [PATCH] findpaths: Add an -a option --- src/bin/findpaths.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/bin/findpaths.cpp b/src/bin/findpaths.cpp index 5b99632fe4..607f9f4d02 100644 --- a/src/bin/findpaths.cpp +++ b/src/bin/findpaths.cpp @@ -92,6 +92,12 @@ static const char* kUsage = "modify this behavior.\n" "\n" "Options:\n" + " -a \n" + " If the path(s) specified by are architecture specific, use\n" + " architecture . If not specified, the primary\n" + " architecture is used, unless the -p/--path option is specified, in\n" + " which case the architecture associated with the given is\n" + " used.\n" " -c \n" " Concatenate the resulting paths, separated only by ,\n" " instead of printing a path per line.\n" @@ -123,6 +129,7 @@ print_usage_and_exit(bool error) int main(int argc, const char* const* argv) { + const char* architecture = NULL; const char* dependency = NULL; const char* referencePath = NULL; bool existingOnly = false; @@ -130,6 +137,7 @@ main(int argc, const char* const* argv) while (true) { static struct option sLongOptions[] = { + { "architecture", required_argument, 0, 'a' }, { "dependency", required_argument, 0, 'd' }, { "help", no_argument, 0, 'h' }, { "path", required_argument, 0, 'p' }, @@ -137,12 +145,16 @@ main(int argc, const char* const* argv) }; opterr = 0; // don't print errors - int c = getopt_long(argc, (char**)argv, "+c:d:ehlp:", + int c = getopt_long(argc, (char**)argv, "+a:c:d:ehlp:", sLongOptions, NULL); if (c == -1) break; switch (c) { + case 'a': + architecture = optarg; + break; + case 'c': separator = optarg; break; @@ -208,7 +220,7 @@ main(int argc, const char* const* argv) if (referencePath != NULL) { BPath path; status_t error = BPathFinder(referencePath, dependency).FindPath( - baseDirectory, subPath, + architecture, baseDirectory, subPath, existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, path); if (error != B_OK) { fprintf(stderr, "Error: Failed to find path: %s\n", @@ -219,8 +231,8 @@ main(int argc, const char* const* argv) printf("%s\n", path.Path()); } else { BStringList paths; - status_t error = BPathFinder::FindPaths(baseDirectory, subPath, - existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, paths); + status_t error = BPathFinder::FindPaths(architecture, baseDirectory, + subPath, existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, paths); if (error != B_OK) { fprintf(stderr, "Error: Failed to find paths: %s\n", strerror(error));