findpaths: Add an -a <architecture> option
This commit is contained in:
+16
-4
@@ -92,6 +92,12 @@ static const char* kUsage =
|
|||||||
"modify this behavior.\n"
|
"modify this behavior.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
|
" -a <architecture>\n"
|
||||||
|
" If the path(s) specified by <kind> are architecture specific, use\n"
|
||||||
|
" architecture <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 <path> is\n"
|
||||||
|
" used.\n"
|
||||||
" -c <separator>\n"
|
" -c <separator>\n"
|
||||||
" Concatenate the resulting paths, separated only by <separator>,\n"
|
" Concatenate the resulting paths, separated only by <separator>,\n"
|
||||||
" instead of printing a path per line.\n"
|
" instead of printing a path per line.\n"
|
||||||
@@ -123,6 +129,7 @@ print_usage_and_exit(bool error)
|
|||||||
int
|
int
|
||||||
main(int argc, const char* const* argv)
|
main(int argc, const char* const* argv)
|
||||||
{
|
{
|
||||||
|
const char* architecture = NULL;
|
||||||
const char* dependency = NULL;
|
const char* dependency = NULL;
|
||||||
const char* referencePath = NULL;
|
const char* referencePath = NULL;
|
||||||
bool existingOnly = false;
|
bool existingOnly = false;
|
||||||
@@ -130,6 +137,7 @@ main(int argc, const char* const* argv)
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
static struct option sLongOptions[] = {
|
static struct option sLongOptions[] = {
|
||||||
|
{ "architecture", required_argument, 0, 'a' },
|
||||||
{ "dependency", required_argument, 0, 'd' },
|
{ "dependency", required_argument, 0, 'd' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ "path", required_argument, 0, 'p' },
|
{ "path", required_argument, 0, 'p' },
|
||||||
@@ -137,12 +145,16 @@ main(int argc, const char* const* argv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
opterr = 0; // don't print errors
|
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);
|
sLongOptions, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'a':
|
||||||
|
architecture = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
separator = optarg;
|
separator = optarg;
|
||||||
break;
|
break;
|
||||||
@@ -208,7 +220,7 @@ main(int argc, const char* const* argv)
|
|||||||
if (referencePath != NULL) {
|
if (referencePath != NULL) {
|
||||||
BPath path;
|
BPath path;
|
||||||
status_t error = BPathFinder(referencePath, dependency).FindPath(
|
status_t error = BPathFinder(referencePath, dependency).FindPath(
|
||||||
baseDirectory, subPath,
|
architecture, baseDirectory, subPath,
|
||||||
existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, path);
|
existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, path);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
fprintf(stderr, "Error: Failed to find path: %s\n",
|
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());
|
printf("%s\n", path.Path());
|
||||||
} else {
|
} else {
|
||||||
BStringList paths;
|
BStringList paths;
|
||||||
status_t error = BPathFinder::FindPaths(baseDirectory, subPath,
|
status_t error = BPathFinder::FindPaths(architecture, baseDirectory,
|
||||||
existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, paths);
|
subPath, existingOnly ? B_FIND_PATH_EXISTING_ONLY : 0, paths);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
fprintf(stderr, "Error: Failed to find paths: %s\n",
|
fprintf(stderr, "Error: Failed to find paths: %s\n",
|
||||||
strerror(error));
|
strerror(error));
|
||||||
|
|||||||
Reference in New Issue
Block a user