mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
fc6d051dfd
The LexicalPath instance methods dirname(), basename(), title() and extension() will be changed to return StringView const& in a further commit. Due to this, users creating temporary LexicalPath objects just to call one of those getters will recieve a StringView const& pointing to a possible freed buffer. To avoid this, static methods for those APIs have been added, which will return a String by value to avoid those problems. All cases where temporary LexicalPath objects have been used as described above haven been changed to use the static APIs.
20 lines
433 B
C++
20 lines
433 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/LexicalPath.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
const char* path = nullptr;
|
|
Core::ArgsParser args_parser;
|
|
args_parser.add_positional_argument(path, "Path", "path");
|
|
args_parser.parse(argc, argv);
|
|
|
|
outln("{}", LexicalPath::dirname(path));
|
|
return 0;
|
|
}
|