filepanel: Fix -Wformat-security and remove unused options.
Change-Id: Iedf3bb500de15a29188c30940b5fd64dcaf043f5 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3319 Reviewed-by: Niels Sascha Reedijk <niels.reedijk@gmail.com>
This commit is contained in:
parent
e5feb3a7ae
commit
08f2b4d50a
@ -37,7 +37,7 @@ class FilePanelApp : public BApplication
|
||||
{
|
||||
public:
|
||||
FilePanelApp();
|
||||
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void RefsReceived(BMessage *message);
|
||||
};
|
||||
@ -49,7 +49,7 @@ FilePanelApp::FilePanelApp()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
FilePanelApp::MessageReceived(BMessage *message)
|
||||
{
|
||||
entry_ref e;
|
||||
@ -77,7 +77,7 @@ FilePanelApp::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
FilePanelApp::RefsReceived(BMessage *message)
|
||||
{
|
||||
entry_ref e;
|
||||
@ -97,37 +97,30 @@ FilePanelApp::RefsReceived(BMessage *message)
|
||||
int
|
||||
usage(char *pname, int error)
|
||||
{
|
||||
fprintf(stderr, B_TRANSLATE("display a load/save file panel\n"));
|
||||
fprintf(stderr, "%s", B_TRANSLATE("display a load/save file panel\n"));
|
||||
fprintf(stderr, B_TRANSLATE("usage: %s [--help] [--directory folder] "
|
||||
"[--load|--save] [--title ttl] [--single] [--modal] [--allow pattern] "
|
||||
"[--forbid pattern]\n"), pname);
|
||||
"[--load|--save] [--title ttl] [--single] [--modal]\n"), pname);
|
||||
fprintf(stderr, B_TRANSLATE("usage: %s [-h] [-d folder] "
|
||||
"[-l|-s] [-t ttl] [-1] [-m] [-a pattern] "
|
||||
"[-f pattern]\n"), pname);
|
||||
fprintf(stderr, B_TRANSLATE("options:\n"));
|
||||
fprintf(stderr, B_TRANSLATE("short\tlong\tdescription\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-h\t--help\tdisplay usage\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-d\t--directory\topen at <folder>\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-l\t--load\tuse a load FilePanel "
|
||||
"(default)\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-s\t--save\tuse a save FilePanel\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-n\t--name\tset the default name for "
|
||||
"saving\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-k\t--kind\tkind of entries that can be "
|
||||
"[-l|-s] [-t ttl] [-1] [-m]"), pname);
|
||||
fprintf(stderr, "%s", B_TRANSLATE("options:\n"));
|
||||
fprintf(stderr, "%s", B_TRANSLATE("short\tlong\tdescription\n"));
|
||||
fprintf(stderr, "%s", B_TRANSLATE("-h\t--help\tdisplay usage\n"));
|
||||
fprintf(stderr, "%s", B_TRANSLATE("-d\t--directory\topen at <folder>\n"));
|
||||
fprintf(stderr, "%s",
|
||||
B_TRANSLATE("-l\t--load\tuse a load FilePanel (default)\n"));
|
||||
fprintf(stderr, "%s", B_TRANSLATE("-s\t--save\tuse a save FilePanel\n"));
|
||||
fprintf(stderr, "%s",
|
||||
B_TRANSLATE("-n\t--name\tset the default name for saving\n"));
|
||||
fprintf(stderr, "%s",
|
||||
B_TRANSLATE("-k\t--kind\tkind of entries that can be "
|
||||
"opened (flavour): any combination of f, d, s (file (default), "
|
||||
"directory, symlink)\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-t\t--title\tset the FilePanel window "
|
||||
"title\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-1\t--single\tallow only 1 file to be "
|
||||
"selected\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-m\t--modal\tmakes the FilePanel modal\n"));
|
||||
#ifndef USE_FNMATCH
|
||||
fprintf(stderr, B_TRANSLATE("-a\t--allow\tunimplemented\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-f\t--forbid\tunimplemented\n"));
|
||||
#else
|
||||
fprintf(stderr, B_TRANSLATE("-a\t--allow\tunimplemented\n"));
|
||||
fprintf(stderr, B_TRANSLATE("-f\t--forbid\tunimplemented\n"));
|
||||
#endif
|
||||
fprintf(stderr, "%s",
|
||||
B_TRANSLATE("-t\t--title\tset the FilePanel window title\n"));
|
||||
fprintf(stderr, "%s",
|
||||
B_TRANSLATE("-1\t--single\tallow only 1 file to be selected\n"));
|
||||
fprintf(stderr, "%s",
|
||||
B_TRANSLATE("-m\t--modal\tmakes the FilePanel modal\n"));
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -145,7 +138,7 @@ main(int argc, char **argv)
|
||||
const char *defaultName = NULL;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp(argv[i], "--", 2) && ((*(argv[i]) == '-' &&
|
||||
if (strncmp(argv[i], "--", 2) && ((*(argv[i]) == '-' &&
|
||||
strlen(argv[i]) != 2) || *(argv[i]) != '-')) {
|
||||
fprintf(stderr, B_TRANSLATE("%s not a valid option\n"), argv[i]);
|
||||
return usage(argv[0], 2);
|
||||
@ -190,20 +183,6 @@ main(int argc, char **argv)
|
||||
allowMultiSelect = false;
|
||||
} else if (!strcmp(argv[i], "--modal") || !strcmp(argv[i], "-m")) {
|
||||
makeModal = true;
|
||||
} else if (!strcmp(argv[i], "--allow") || !strcmp(argv[i], "-a")) {
|
||||
if (++i >= argc) {
|
||||
fprintf(stderr, B_TRANSLATE("%s: this option requires a "
|
||||
"parameter\n"), argv[i-1]);
|
||||
return usage(argv[0], 2);
|
||||
}
|
||||
fprintf(stderr, B_TRANSLATE("%s: UNIMPLEMENTED\n"), argv[i-1]);
|
||||
} else if (!strcmp(argv[i], "--forbid") || !strcmp(argv[i], "-f")) {
|
||||
if (++i >= argc) {
|
||||
fprintf(stderr, B_TRANSLATE("%s: this option requires a "
|
||||
"parameter\n"), argv[i-1]);
|
||||
return usage(argv[0], 2);
|
||||
}
|
||||
fprintf(stderr, B_TRANSLATE("%s: UNIMPLEMENTED\n"), argv[i-1]);
|
||||
} else {
|
||||
fprintf(stderr, B_TRANSLATE("%s not a valid option\n"), argv[i]);
|
||||
return usage(argv[0], 2);
|
||||
@ -211,9 +190,9 @@ main(int argc, char **argv)
|
||||
}
|
||||
new FilePanelApp;
|
||||
entry_ref panelDir;
|
||||
// THIS LINE makes main() return always 0 no matter which value on return of
|
||||
// THIS LINE makes main() return always 0 no matter which value on return of
|
||||
// exit() ???
|
||||
BFilePanel *fPanel = new BFilePanel(fpMode, NULL, NULL, nodeFlavour,
|
||||
BFilePanel *fPanel = new BFilePanel(fpMode, NULL, NULL, nodeFlavour,
|
||||
allowMultiSelect, NULL, NULL, makeModal);
|
||||
/**/
|
||||
if (openAt)
|
||||
@ -222,7 +201,7 @@ main(int argc, char **argv)
|
||||
fPanel->Window()->SetTitle(windowTitle);
|
||||
if (fpMode == B_SAVE_PANEL && defaultName)
|
||||
fPanel->SetSaveText(defaultName);
|
||||
|
||||
|
||||
fPanel->Show();
|
||||
/**/
|
||||
be_app->Run();
|
||||
|
Loading…
Reference in New Issue
Block a user