mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:37:34 +00:00
find: Port to LibMain
This commit is contained in:
parent
c3c2fe153b
commit
4ca35ac1b8
2 changed files with 7 additions and 8 deletions
|
@ -74,6 +74,7 @@ target_link_libraries(echo LibMain)
|
|||
target_link_libraries(expr LibRegex)
|
||||
target_link_libraries(fdtdump LibDeviceTree)
|
||||
target_link_libraries(file LibGfx LibIPC LibCompress)
|
||||
target_link_libraries(find LibMain)
|
||||
target_link_libraries(fortune LibMain)
|
||||
target_link_libraries(functrace LibDebug LibX86)
|
||||
target_link_libraries(gml-format LibGUI)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -563,17 +565,13 @@ static void walk_tree(FileData& root_data, Command& command)
|
|||
closedir(dir);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
LexicalPath root_path(parse_options(argc, argv));
|
||||
LexicalPath root_path(parse_options(arguments.argc, arguments.argv));
|
||||
String dirname = root_path.dirname();
|
||||
String basename = root_path.basename();
|
||||
|
||||
int dirfd = open(dirname.characters(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (dirfd < 0) {
|
||||
perror(dirname.characters());
|
||||
return 1;
|
||||
}
|
||||
int dirfd = TRY(Core::System::open(dirname, O_RDONLY | O_DIRECTORY | O_CLOEXEC));
|
||||
|
||||
FileData file_data {
|
||||
root_path,
|
||||
|
@ -583,7 +581,7 @@ int main(int argc, char* argv[])
|
|||
false,
|
||||
DT_UNKNOWN,
|
||||
};
|
||||
auto command = parse_all_commands(argv);
|
||||
auto command = parse_all_commands(arguments.argv);
|
||||
walk_tree(file_data, *command);
|
||||
close(dirfd);
|
||||
return g_there_was_an_error ? 1 : 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue