Add an -l option to 'query' - enabling lookup of path for localized names (or parts thereof). I'm not sure it should be part of 'query', but here it is. Due to using BString it is currently case-sensitive beyond plain ascii names.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41120 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+5
-1
@@ -100,7 +100,6 @@ StdBinCommands
|
||||
modifiers.cpp
|
||||
open.cpp
|
||||
play.cpp
|
||||
query.cpp
|
||||
quit.cpp
|
||||
roster.cpp
|
||||
setdecor.cpp
|
||||
@@ -129,6 +128,11 @@ StdBinCommands
|
||||
urlwrapper.cpp
|
||||
: be $(TARGET_LIBSUPC++) : $(haiku-utils_rsrc) ;
|
||||
|
||||
# commands that need libbe.so and liblocale.so
|
||||
StdBinCommands
|
||||
query.cpp
|
||||
: be $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ;
|
||||
|
||||
# commands that need libbe.so, libsupc++.so and liblocale.so
|
||||
StdBinCommands
|
||||
dstcheck.cpp
|
||||
|
||||
+32
-10
@@ -13,16 +13,17 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <Entry.h>
|
||||
#include <LocaleRoster.h>
|
||||
#include <Path.h>
|
||||
#include <Query.h>
|
||||
#include <Entry.h>
|
||||
#include <String.h>
|
||||
#include <Volume.h>
|
||||
#include <VolumeRoster.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
@@ -33,6 +34,7 @@ static const char *kProgramName = __progname;
|
||||
static bool sAllVolumes = false; // Query all volumes?
|
||||
static bool sEscapeMetaChars = true; // Escape metacharacters?
|
||||
static bool sFilesOnly = false; // Show only files?
|
||||
static bool sLocalizedAppNames = false; // match localized names
|
||||
|
||||
|
||||
void
|
||||
@@ -41,6 +43,7 @@ usage(void)
|
||||
printf("usage: %s [ -ef ] [ -a || -v <path-to-volume> ] expression\n"
|
||||
" -e\t\tdon't escape meta-characters\n"
|
||||
" -f\t\tshow only files (ie. no directories or symbolic links)\n"
|
||||
" -l\t\tmatch expression with localized application names\n"
|
||||
" -a\t\tperform the query on all volumes\n"
|
||||
" -v <file>\tperform the query on just one volume; <file> can be any\n"
|
||||
"\t\tfile on that volume. Defaults to the current volume.\n"
|
||||
@@ -54,10 +57,12 @@ void
|
||||
perform_query(BVolume &volume, const char *predicate)
|
||||
{
|
||||
BQuery query;
|
||||
|
||||
// Set up the volume and predicate for the query.
|
||||
query.SetVolume(&volume);
|
||||
query.SetPredicate(predicate);
|
||||
|
||||
if (sLocalizedAppNames)
|
||||
query.SetPredicate("BEOS:APP_SIG=*");
|
||||
else
|
||||
query.SetPredicate(predicate);
|
||||
|
||||
status_t status = query.Fetch();
|
||||
if (status == B_BAD_VALUE) {
|
||||
@@ -84,9 +89,23 @@ perform_query(BVolume &volume, const char *predicate)
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s\n", sEscapeMetaChars ?
|
||||
BString().CharacterEscape(path.Path(), " ()?*&\"'[]^\\~|;!<>*$\t", '\\').String()
|
||||
: path.Path());
|
||||
BString string;
|
||||
if (sLocalizedAppNames && predicate != NULL) {
|
||||
entry_ref ref;
|
||||
|
||||
if (entry.GetRef(&ref) != B_OK || BLocaleRoster::Default()
|
||||
->GetLocalizedFileName(ref, string) != B_OK)
|
||||
continue;
|
||||
|
||||
if (string.IFindFirst(predicate) < 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
string = path.Path();
|
||||
if (sEscapeMetaChars)
|
||||
string.CharacterEscape(" ()?*&\"'[]^\\~|;!<>*$\t", '\\');
|
||||
|
||||
printf("%s\n", string.String());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +124,7 @@ main(int argc, char **argv)
|
||||
|
||||
// Parse command-line arguments.
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "efav:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "efalv:")) != -1) {
|
||||
switch(opt) {
|
||||
case 'e':
|
||||
sEscapeMetaChars = false;
|
||||
@@ -116,6 +135,9 @@ main(int argc, char **argv)
|
||||
case 'a':
|
||||
sAllVolumes = true;
|
||||
break;
|
||||
case 'l':
|
||||
sLocalizedAppNames = true;
|
||||
break;
|
||||
case 'v':
|
||||
strlcpy(volumePath, optarg, B_FILE_NAME_LENGTH);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user