1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:37:44 +00:00

Utilities: Use Vector<String> positional arguments in some places

There are more places we can use these, I just picked some that felt
like they improved the code.
This commit is contained in:
Andreas Kling 2021-04-29 11:28:01 +02:00
parent 695cdf7bc0
commit 39369f1da6
6 changed files with 15 additions and 17 deletions

View file

@ -6,13 +6,11 @@
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char** argv)
@ -22,7 +20,7 @@ int main(int argc, char** argv)
return 1;
}
Vector<const char*> paths;
Vector<String> paths;
Core::ArgsParser args_parser;
args_parser.set_general_help("Concatenate files or pipes to stdout.");
@ -31,12 +29,12 @@ int main(int argc, char** argv)
Vector<int> fds;
if (!paths.is_empty()) {
for (const char* path : paths) {
for (auto const& path : paths) {
int fd;
if (StringView { path } == "-") {
if (path == "-") {
fd = 0;
} else if ((fd = open(path, O_RDONLY)) == -1) {
fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
} else if ((fd = open(path.characters(), O_RDONLY)) == -1) {
warnln("Failed to open {}: {}", path, strerror(errno));
continue;
}
fds.append(fd);