mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:07:44 +00:00
LibCore: Move Stream-based file into the Core
namespace
This commit is contained in:
parent
a96339b72b
commit
606a3982f3
218 changed files with 748 additions and 643 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/QuickSort.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -92,7 +93,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln();
|
||||
|
||||
if (!flag_set && !flag_delete) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/arp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/net/arp"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/Base64.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -22,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(filepath, "", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(filepath, Core::File::OpenMode::Read));
|
||||
ByteBuffer buffer = TRY(file->read_until_eof());
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -25,11 +26,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (paths.is_empty())
|
||||
paths.append("-"sv);
|
||||
|
||||
Vector<NonnullOwnPtr<Core::Stream::File>> files;
|
||||
Vector<NonnullOwnPtr<Core::File>> files;
|
||||
TRY(files.try_ensure_capacity(paths.size()));
|
||||
|
||||
for (auto const& path : paths) {
|
||||
if (auto result = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read); result.is_error())
|
||||
if (auto result = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read); result.is_error())
|
||||
warnln("Failed to open {}: {}", path, result.release_error());
|
||||
else
|
||||
files.unchecked_append(result.release_value());
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCrypto/Hash/HashManager.h>
|
||||
|
@ -55,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
int failed_verification_count = 0;
|
||||
|
||||
for (auto const& path : paths) {
|
||||
auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
++read_fail_count;
|
||||
has_error = true;
|
||||
|
@ -87,7 +88,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
// line[0] = checksum
|
||||
// line[1] = filename
|
||||
StringView const filename = line[1];
|
||||
auto file_from_filename_or_error = Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read);
|
||||
auto file_from_filename_or_error = Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read);
|
||||
if (file_from_filename_or_error.is_error()) {
|
||||
++read_fail_count;
|
||||
warnln("{}: {}", filename, file_from_filename_or_error.release_error());
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCrypto/Checksum/Adler32.h>
|
||||
|
@ -46,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
Array<u8, PAGE_SIZE> buffer;
|
||||
|
||||
for (auto& path : paths) {
|
||||
auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
|
||||
auto filepath = (path == "-") ? "/dev/stdin" : path;
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("{}: {}: {}", arguments.strings[0], filepath, file_or_error.error());
|
||||
|
|
|
@ -5,20 +5,21 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<Core::Stream::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename)
|
||||
static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename)
|
||||
{
|
||||
OwnPtr<Core::Stream::File> file;
|
||||
OwnPtr<Core::File> file;
|
||||
if (filename == "-") {
|
||||
file = TRY(Core::Stream::File::adopt_fd(STDIN_FILENO, Core::Stream::OpenMode::Read));
|
||||
file = TRY(Core::File::adopt_fd(STDIN_FILENO, Core::File::OpenMode::Read));
|
||||
} else {
|
||||
file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
|
||||
file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
|
||||
}
|
||||
return TRY(Core::Stream::BufferedFile::create(file.release_nonnull()));
|
||||
return TRY(Core::BufferedFile::create(file.release_nonnull()));
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -62,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
auto open_file = [](DeprecatedString const& path, auto& file, int file_number) {
|
||||
auto file_or_error = Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Failed to open file{} '{}': {}", file_number, path, file_or_error.error());
|
||||
return false;
|
||||
|
@ -73,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return false;
|
||||
}
|
||||
|
||||
auto buffered_file_or_error = Core::Stream::BufferedFile::create(file_or_error.release_value());
|
||||
auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value());
|
||||
if (buffered_file_or_error.is_error()) {
|
||||
warnln("Failed to create buffer for file{} '{}': {}", file_number, path, buffered_file_or_error.error());
|
||||
return false;
|
||||
|
@ -83,8 +84,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return true;
|
||||
};
|
||||
|
||||
OwnPtr<Core::Stream::BufferedFile> file1;
|
||||
OwnPtr<Core::Stream::BufferedFile> file2;
|
||||
OwnPtr<Core::BufferedFile> file1;
|
||||
OwnPtr<Core::BufferedFile> file2;
|
||||
if (!(open_file(file1_path, file1, 1) && open_file(file2_path, file2, 2)))
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
|
@ -42,7 +43,7 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
|
|||
// We're not copying anything.
|
||||
} else if (text.is_empty()) {
|
||||
// Copy our stdin.
|
||||
auto c_stdin = TRY(Core::Stream::File::standard_input());
|
||||
auto c_stdin = TRY(Core::File::standard_input());
|
||||
auto buffer = TRY(c_stdin->read_until_eof());
|
||||
dbgln("Read size {}", buffer.size());
|
||||
dbgln("Read data: `{}`", StringView(buffer.bytes()));
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/Try.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCpp/Lexer.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -17,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::Yes);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto content = TRY(file->read_until_eof());
|
||||
StringView content_view(content);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCpp/Parser.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -20,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (path.is_empty())
|
||||
path = "Source/little/main.cpp"sv;
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto content = TRY(file->read_until_eof());
|
||||
StringView content_view(content);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCpp/Preprocessor.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -19,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(print_definitions, "Print preprocessor definitions", "definitions", 'D');
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto content = TRY(file->read_until_eof());
|
||||
DeprecatedString name = LexicalPath::basename(path);
|
||||
Cpp::Preprocessor cpp(name, StringView { content });
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -36,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(flag_inode_info, "Show inode information as well", "inodes", 'i');
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read));
|
||||
|
||||
Vector<StringView> headers;
|
||||
TRY(headers.try_append(flag_human_readable ? "Size"sv : "Blocks"sv));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibDiff/Generator.h>
|
||||
|
@ -23,8 +24,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
parser.add_positional_argument(filename2, "Second file to compare", "file2", Core::ArgsParser::Required::Yes);
|
||||
parser.parse(arguments);
|
||||
|
||||
auto file1 = TRY(Core::Stream::File::open(filename1, Core::Stream::OpenMode::Read));
|
||||
auto file2 = TRY(Core::Stream::File::open(filename2, Core::Stream::OpenMode::Read));
|
||||
auto file1 = TRY(Core::File::open(filename1, Core::File::OpenMode::Read));
|
||||
auto file2 = TRY(Core::File::open(filename2, Core::File::OpenMode::Read));
|
||||
|
||||
bool color_output = TRY(Core::System::isatty(STDOUT_FILENO));
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil("/sys/kernel/dmesg", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/dmesg"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/dmesg"sv, Core::File::OpenMode::Read));
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
out("{}", StringView { buffer });
|
||||
return 0;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -116,7 +117,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
|
|||
if (!pattern.is_empty())
|
||||
du_option.excluded_patterns.append(pattern);
|
||||
if (!exclude_from.is_empty()) {
|
||||
auto file = TRY(Core::Stream::File::open(exclude_from, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(exclude_from, Core::File::OpenMode::Read));
|
||||
auto const buff = TRY(file->read_until_eof());
|
||||
if (!buff.is_empty()) {
|
||||
DeprecatedString patterns = DeprecatedString::copy(buff, Chomp);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCompress/Gzip.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
@ -158,7 +159,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto buffer = TRY(ByteBuffer::create_uninitialized(0x9006));
|
||||
|
||||
for (auto const& path : paths) {
|
||||
auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
perror(path.characters());
|
||||
all_ok = false;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -81,7 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(path, "Path to JSON file with quotes (/res/fortunes.json by default)", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::unveil("/etc/timezone", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/GML/Formatter.h>
|
||||
|
@ -13,8 +14,8 @@
|
|||
static ErrorOr<bool> format_file(StringView path, bool inplace)
|
||||
{
|
||||
auto read_from_stdin = path == "-";
|
||||
auto open_mode = (inplace && !read_from_stdin) ? Core::Stream::OpenMode::ReadWrite : Core::Stream::OpenMode::Read;
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, open_mode));
|
||||
auto open_mode = (inplace && !read_from_stdin) ? Core::File::OpenMode::ReadWrite : Core::File::OpenMode::Read;
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, open_mode));
|
||||
|
||||
auto contents = TRY(file->read_until_eof());
|
||||
auto formatted_gml_or_error = GUI::GML::format_gml(contents);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -215,8 +216,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
|
||||
auto handle_file = [&matches, binary_mode, count_lines, quiet_mode,
|
||||
user_specified_multiple_files, &matched_line_count, &did_match_something](StringView filename, bool print_filename) -> ErrorOr<void> {
|
||||
auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
|
||||
auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file)));
|
||||
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
|
||||
auto buffered_file = TRY(Core::BufferedFile::create(move(file)));
|
||||
|
||||
for (size_t line_number = 1; TRY(buffered_file->can_read_line()); ++line_number) {
|
||||
Array<u8, PAGE_SIZE> buffer;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/JsonValue.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -54,7 +55,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(path, "Input", "input", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
|
||||
#include <LibCompress/Gzip.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::Stream::File> input_stream, AK::Stream& output_stream)
|
||||
static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::File> input_stream, AK::Stream& output_stream)
|
||||
{
|
||||
auto gzip_stream = Compress::GzipDecompressor { move(input_stream) };
|
||||
|
||||
|
@ -50,8 +51,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
output_filename = filename;
|
||||
}
|
||||
|
||||
auto input_stream_result = TRY(Core::Stream::File::open(input_filename, Core::Stream::OpenMode::Read));
|
||||
auto output_stream = write_to_stdout ? TRY(Core::Stream::File::standard_output()) : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
|
||||
auto input_stream_result = TRY(Core::File::open(input_filename, Core::File::OpenMode::Read));
|
||||
auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
|
||||
|
||||
TRY(decompress_file(move(input_stream_result), *output_stream));
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibCompress/Gzip.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -55,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
else
|
||||
output_bytes = TRY(Compress::GzipCompressor::compress_all(input_bytes));
|
||||
|
||||
auto output_stream = write_to_stdout ? TRY(Core::Stream::File::standard_output()) : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
|
||||
auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
|
||||
TRY(output_stream->write_entire_buffer(output_bytes));
|
||||
|
||||
if (!keep_input_files) {
|
||||
|
|
|
@ -694,7 +694,7 @@ static void load_page_for_screenshot_and_exit(HeadlessBrowserPageClient& page_cl
|
|||
if (Core::DeprecatedFile::exists(output_file_path))
|
||||
MUST(Core::DeprecatedFile::remove(output_file_path, Core::DeprecatedFile::RecursionMode::Disallowed));
|
||||
|
||||
auto output_file = MUST(Core::Stream::File::open(output_file_path, Core::Stream::OpenMode::Write));
|
||||
auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write));
|
||||
|
||||
auto output_rect = page_client.screen_rect();
|
||||
auto output_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, output_rect.size().to_type<int>()));
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -37,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
args_parser.add_option(seek_to, "Seek to a byte offset", "seek", 's', "offset");
|
||||
args_parser.parse(args);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
|
||||
if (seek_to.has_value())
|
||||
TRY(file->seek(seek_to.value(), SeekMode::SetPosition));
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -31,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
if (value_ipv4.is_empty() && value_adapter.is_empty() && value_mask.is_empty()) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/net/adapters"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ enum class PrintTarget {
|
|||
|
||||
static ErrorOr<void> print(JS::Value value, PrintTarget target = PrintTarget::StandardOutput)
|
||||
{
|
||||
auto stream = TRY(target == PrintTarget::StandardError ? Core::Stream::File::standard_error() : Core::Stream::File::standard_output());
|
||||
auto stream = TRY(target == PrintTarget::StandardError ? Core::File::standard_error() : Core::File::standard_output());
|
||||
return print(value, *stream);
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ static ErrorOr<String> read_next_piece()
|
|||
|
||||
static ErrorOr<void> write_to_file(String const& path)
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write, 0666));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Write, 0666));
|
||||
for (size_t i = 0; i < g_repl_statements.size(); i++) {
|
||||
auto line = g_repl_statements[i].bytes();
|
||||
if (line.size() > 0 && i != g_repl_statements.size() - 1) {
|
||||
|
@ -334,7 +334,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
|
|||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error())
|
||||
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
|
||||
|
||||
|
@ -354,7 +354,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
|
|||
static JS::ThrowCompletionOr<JS::Value> load_json_impl(JS::VM& vm)
|
||||
{
|
||||
auto filename = TRY(vm.argument(0).to_string(vm));
|
||||
auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error())
|
||||
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
|
||||
|
||||
|
@ -871,7 +871,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
warnln("Warning: Multiple files supplied, this will concatenate the sources and resolve modules as if it was the first file");
|
||||
|
||||
for (auto& path : script_paths) {
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto source = StringView { file_contents };
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -43,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
VERIFY(spaces_in_indent >= 0);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -38,19 +39,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
while (di.has_next()) {
|
||||
auto dir = di.next_path();
|
||||
auto command_set_filename = DeprecatedString::formatted("/sys/devices/storage/{}/command_set", dir);
|
||||
auto command_set_file = Core::Stream::File::open(command_set_filename, Core::Stream::OpenMode::Read);
|
||||
auto command_set_file = Core::File::open(command_set_filename, Core::File::OpenMode::Read);
|
||||
if (command_set_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", command_set_filename, command_set_file.error());
|
||||
continue;
|
||||
}
|
||||
auto last_lba_filename = DeprecatedString::formatted("/sys/devices/storage/{}/last_lba", dir);
|
||||
auto last_lba_file = Core::Stream::File::open(last_lba_filename, Core::Stream::OpenMode::Read);
|
||||
auto last_lba_file = Core::File::open(last_lba_filename, Core::File::OpenMode::Read);
|
||||
if (last_lba_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", last_lba_filename, last_lba_file.error());
|
||||
continue;
|
||||
}
|
||||
auto sector_size_filename = DeprecatedString::formatted("/sys/devices/storage/{}/sector_size", dir);
|
||||
auto sector_size_file = Core::Stream::File::open(sector_size_filename, Core::Stream::OpenMode::Read);
|
||||
auto sector_size_file = Core::File::open(sector_size_filename, Core::File::OpenMode::Read);
|
||||
if (sector_size_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", sector_size_filename, sector_size_file.error());
|
||||
continue;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -59,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil("/sys/kernel/cpuinfo", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
auto const& array = json.as_array();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -17,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil("/sys/kernel/interrupts", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto proc_interrupts = TRY(Core::Stream::File::open("/sys/kernel/interrupts"sv, Core::Stream::OpenMode::Read));
|
||||
auto proc_interrupts = TRY(Core::File::open("/sys/kernel/interrupts"sv, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -16,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil("/sys/kernel/jails", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto jails_data = TRY(Core::Stream::File::open("/sys/kernel/jails"sv, Core::Stream::OpenMode::Read));
|
||||
auto jails_data = TRY(Core::File::open("/sys/kernel/jails"sv, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/JsonValue.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -65,7 +66,7 @@ static bool parse_name(StringView name, OpenFile& file)
|
|||
|
||||
static Vector<OpenFile> get_open_files_by_pid(pid_t pid)
|
||||
{
|
||||
auto file = Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::Stream::OpenMode::Read);
|
||||
auto file = Core::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::File::OpenMode::Read);
|
||||
if (file.is_error()) {
|
||||
outln("lsof: PID {}: {}", pid, file.error());
|
||||
return Vector<OpenFile>();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -89,31 +90,31 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto function = convert_sysfs_value_to_uint(function_parts[1]);
|
||||
|
||||
auto vendor_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/vendor", dir);
|
||||
auto vendor_id_file = Core::Stream::File::open(vendor_id_filename, Core::Stream::OpenMode::Read);
|
||||
auto vendor_id_file = Core::File::open(vendor_id_filename, Core::File::OpenMode::Read);
|
||||
if (vendor_id_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", vendor_id_filename, vendor_id_file.error());
|
||||
continue;
|
||||
}
|
||||
auto device_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/device_id", dir);
|
||||
auto device_id_file = Core::Stream::File::open(device_id_filename, Core::Stream::OpenMode::Read);
|
||||
auto device_id_file = Core::File::open(device_id_filename, Core::File::OpenMode::Read);
|
||||
if (device_id_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", device_id_filename, device_id_file.error());
|
||||
continue;
|
||||
}
|
||||
auto class_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/class", dir);
|
||||
auto class_id_file = Core::Stream::File::open(class_id_filename, Core::Stream::OpenMode::Read);
|
||||
auto class_id_file = Core::File::open(class_id_filename, Core::File::OpenMode::Read);
|
||||
if (class_id_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", class_id_filename, class_id_file.error());
|
||||
continue;
|
||||
}
|
||||
auto subclass_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/subclass", dir);
|
||||
auto subclass_id_file = Core::Stream::File::open(subclass_id_filename, Core::Stream::OpenMode::Read);
|
||||
auto subclass_id_file = Core::File::open(subclass_id_filename, Core::File::OpenMode::Read);
|
||||
if (subclass_id_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", subclass_id_filename, subclass_id_file.error());
|
||||
continue;
|
||||
}
|
||||
auto revision_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/revision", dir);
|
||||
auto revision_id_file = Core::Stream::File::open(revision_id_filename, Core::Stream::OpenMode::Read);
|
||||
auto revision_id_file = Core::File::open(revision_id_filename, Core::File::OpenMode::Read);
|
||||
if (revision_id_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", revision_id_filename, revision_id_file.error());
|
||||
continue;
|
||||
|
@ -177,7 +178,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
continue;
|
||||
for (size_t bar_index = 0; bar_index <= 5; bar_index++) {
|
||||
auto bar_value_filename = DeprecatedString::formatted("/sys/bus/pci/{}/bar{}", dir, bar_index);
|
||||
auto bar_value_file = Core::Stream::File::open(bar_value_filename, Core::Stream::OpenMode::Read);
|
||||
auto bar_value_file = Core::File::open(bar_value_filename, Core::File::OpenMode::Read);
|
||||
if (bar_value_file.is_error()) {
|
||||
dbgln("Error: Could not open {}: {}", bar_value_filename, bar_value_file.error());
|
||||
continue;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -48,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
while (usb_devices.has_next()) {
|
||||
auto full_path = LexicalPath(usb_devices.next_full_path());
|
||||
|
||||
auto proc_usb_device = Core::Stream::File::open(full_path.string(), Core::Stream::OpenMode::Read);
|
||||
auto proc_usb_device = Core::File::open(full_path.string(), Core::File::OpenMode::Read);
|
||||
if (proc_usb_device.is_error()) {
|
||||
warnln("Failed to open {}: {}", full_path.string(), proc_usb_device.error());
|
||||
continue;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -84,7 +85,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
.to_deprecated_string();
|
||||
pid_t pager_pid = TRY(pipe_to_pager(pager));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(TRY(page->path()), Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(TRY(page->path()), Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio proc"));
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
|
@ -249,7 +250,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln("Reading and parsing Markdown files ...");
|
||||
HashMap<DeprecatedString, MarkdownLinkage> files;
|
||||
for (auto path : file_paths) {
|
||||
auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Failed to open {}: {}", path, file_or_error.error());
|
||||
// Since this should never happen anyway, fail early.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -41,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
}
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/JsonValue.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -112,8 +113,8 @@ static ErrorOr<void> mount_all()
|
|||
|
||||
bool all_ok = true;
|
||||
auto process_fstab_entries = [&](StringView path) -> ErrorOr<void> {
|
||||
auto file_unbuffered = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::Stream::BufferedFile::create(move(file_unbuffered)));
|
||||
auto file_unbuffered = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto file = TRY(Core::BufferedFile::create(move(file_unbuffered)));
|
||||
|
||||
while (TRY(file->can_read_line())) {
|
||||
auto line = TRY(file->read_line(buffer));
|
||||
|
@ -148,7 +149,7 @@ static ErrorOr<void> mount_all()
|
|||
static ErrorOr<void> print_mounts()
|
||||
{
|
||||
// Output info about currently mounted filesystems.
|
||||
auto df = TRY(Core::Stream::File::open("/sys/kernel/df"sv, Core::Stream::OpenMode::Read));
|
||||
auto df = TRY(Core::File::open("/sys/kernel/df"sv, Core::File::OpenMode::Read));
|
||||
|
||||
auto content = TRY(df->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(content));
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -154,7 +155,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
if (!has_protocol_flag || flag_tcp) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/tcp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/net/tcp"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json_or_error = JsonValue::from_string(file_contents);
|
||||
if (json_or_error.is_error()) {
|
||||
|
@ -246,7 +247,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
if (!has_protocol_flag || flag_udp) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/udp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/net/udp"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -13,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
{
|
||||
TRY(Core::System::pledge("stdio rpath"sv));
|
||||
|
||||
auto file_or_error = Core::Stream::File::open("/etc/nologin"sv, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open("/etc/nologin"sv, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
outln("This account is currently not available.");
|
||||
} else {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -12,7 +13,7 @@
|
|||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
TRY(Core::System::pledge("stdio rpath"));
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
|
||||
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(buffer));
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -26,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(pid, "PID", "PID", Core::ArgsParser::Required::Yes);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::File::OpenMode::Read));
|
||||
|
||||
outln("{}:", pid);
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
RefPtr<Protocol::Request> request;
|
||||
auto protocol_client = TRY(Protocol::RequestClient::try_create());
|
||||
auto output_stream = ConditionalOutputStream { [&] { return should_save_stream_data; }, TRY(Core::Stream::File::adopt_fd(output_fd, Core::Stream::OpenMode::Write)) };
|
||||
auto output_stream = ConditionalOutputStream { [&] { return should_save_stream_data; }, TRY(Core::File::adopt_fd(output_fd, Core::File::OpenMode::Write)) };
|
||||
|
||||
// https://httpwg.org/specs/rfc9110.html#authentication
|
||||
auto const has_credentials = !credentials.is_empty();
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/power_state"sv, Core::Stream::OpenMode::Write));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
|
||||
|
||||
const DeprecatedString file_contents = "1";
|
||||
TRY(file->write(file_contents.bytes()));
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/QuickSort.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -89,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
};
|
||||
|
||||
if (modify_action.is_empty()) {
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/route"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/net/route"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/GenericLexer.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -116,17 +117,17 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
|
||||
auto command = TRY(parse_command(command_input));
|
||||
|
||||
Optional<NonnullOwnPtr<Core::Stream::File>> maybe_output_file;
|
||||
Optional<NonnullOwnPtr<Core::File>> maybe_output_file;
|
||||
if (command.output_filepath.has_value())
|
||||
maybe_output_file = TRY(Core::Stream::File::open_file_or_standard_stream(command.output_filepath.release_value(), Core::Stream::OpenMode::Write));
|
||||
maybe_output_file = TRY(Core::File::open_file_or_standard_stream(command.output_filepath.release_value(), Core::File::OpenMode::Write));
|
||||
|
||||
if (filepaths.is_empty())
|
||||
filepaths = { "-"sv };
|
||||
|
||||
Array<u8, PAGE_SIZE> buffer {};
|
||||
for (auto const& filepath : filepaths) {
|
||||
auto file_unbuffered = TRY(Core::Stream::File::open_file_or_standard_stream(filepath, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::Stream::BufferedFile::create(move(file_unbuffered)));
|
||||
auto file_unbuffered = TRY(Core::File::open_file_or_standard_stream(filepath, Core::File::OpenMode::Read));
|
||||
auto file = TRY(Core::BufferedFile::create(move(file_unbuffered)));
|
||||
|
||||
while (!file->is_eof()) {
|
||||
auto line = TRY(file->read_line(buffer));
|
||||
|
|
|
@ -161,7 +161,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (edit_image)
|
||||
output_path = Core::DateTime::now().to_deprecated_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
|
||||
|
||||
auto file_or_error = Core::Stream::File::open(output_path, Core::Stream::OpenMode::ReadWrite);
|
||||
auto file_or_error = Core::File::open(output_path, Core::File::OpenMode::ReadWrite);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Could not open '{}' for writing: {}", output_path, file_or_error.error());
|
||||
return 1;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/Random.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -28,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
|
||||
ByteBuffer buffer = TRY(file->read_until_eof());
|
||||
|
||||
u8 input_delimiter = is_zero_terminated ? '\0' : '\n';
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -14,7 +15,7 @@
|
|||
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/power_state"sv, Core::Stream::OpenMode::Write));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
|
||||
|
||||
const DeprecatedString file_contents = "2";
|
||||
TRY(file->write(file_contents.bytes()));
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/QuickSort.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -60,8 +61,8 @@ struct Options {
|
|||
|
||||
static ErrorOr<void> load_file(Options options, StringView filename, Vector<Line>& lines, HashTable<Line>& seen)
|
||||
{
|
||||
auto file = TRY(Core::Stream::BufferedFile::create(
|
||||
TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read))));
|
||||
auto file = TRY(Core::BufferedFile::create(
|
||||
TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read))));
|
||||
|
||||
// FIXME: Unlimited line length
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||
|
|
|
@ -152,7 +152,7 @@ private:
|
|||
NonnullRefPtr<SQL::SQLClient> m_sql_client;
|
||||
SQL::ConnectionID m_connection_id { 0 };
|
||||
Core::EventLoop& m_loop;
|
||||
OwnPtr<Core::Stream::BufferedFile> m_input_file { nullptr };
|
||||
OwnPtr<Core::BufferedFile> m_input_file { nullptr };
|
||||
bool m_quit_when_files_read { false };
|
||||
Vector<DeprecatedString> m_input_file_chain {};
|
||||
Array<u8, 4096> m_buffer {};
|
||||
|
@ -161,13 +161,13 @@ private:
|
|||
{
|
||||
if (!m_input_file && !m_input_file_chain.is_empty()) {
|
||||
auto file_name = m_input_file_chain.take_first();
|
||||
auto file_or_error = Core::Stream::File::open(file_name, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(file_name, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Input file {} could not be opened: {}", file_name, file_or_error.error());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto buffered_file_or_error = Core::Stream::BufferedFile::create(file_or_error.release_value());
|
||||
auto buffered_file_or_error = Core::BufferedFile::create(file_or_error.release_value());
|
||||
if (buffered_file_or_error.is_error()) {
|
||||
warnln("Input file {} could not be buffered: {}", file_name, buffered_file_or_error.error());
|
||||
return {};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/Types.h>
|
||||
#include <Kernel/API/SyscallString.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -836,8 +837,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
parser.parse(arguments);
|
||||
|
||||
auto trace_file = output_filename.is_empty()
|
||||
? TRY(Core::Stream::File::standard_error())
|
||||
: TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write));
|
||||
? TRY(Core::File::standard_error())
|
||||
: TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));
|
||||
|
||||
auto parse_syscalls = [](char const* option, auto& hash_table) {
|
||||
if (option != nullptr) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -67,7 +68,7 @@ static ErrorOr<void> process_strings_in_file(StringView path, bool show_paths, S
|
|||
{
|
||||
Array<u8, buffer_read_size> buffer;
|
||||
Vector<u8> output_characters;
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
|
||||
size_t processed_characters = 0;
|
||||
size_t string_offset_position = 0;
|
||||
bool did_show_path = false;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
|
@ -15,7 +16,7 @@ static bool s_set_variable = false;
|
|||
static DeprecatedString get_variable(StringView name)
|
||||
{
|
||||
auto path = DeprecatedString::formatted("/sys/kernel/variables/{}", name);
|
||||
auto file = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
if (file.is_error()) {
|
||||
warnln("Failed to open {}: {}", path, file.error());
|
||||
return {};
|
||||
|
@ -43,7 +44,7 @@ static bool write_variable(StringView name, StringView value)
|
|||
if (old_value.is_null())
|
||||
return false;
|
||||
auto path = DeprecatedString::formatted("/sys/kernel/variables/{}", name);
|
||||
auto file = Core::Stream::File::open(path, Core::Stream::OpenMode::Write);
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Write);
|
||||
if (file.is_error()) {
|
||||
warnln("Failed to open {}: {}", path, file.error());
|
||||
return false;
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/FileWatcher.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
|
||||
#define DEFAULT_LINE_COUNT 10
|
||||
|
||||
static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline)
|
||||
static ErrorOr<void> tail_from_pos(Core::File& file, off_t startline)
|
||||
{
|
||||
TRY(file.seek(startline + 1, SeekMode::SetPosition));
|
||||
auto buffer = TRY(file.read_until_eof());
|
||||
|
@ -20,7 +21,7 @@ static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline)
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<off_t> find_seek_pos(Core::Stream::File& file, int wanted_lines)
|
||||
static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines)
|
||||
{
|
||||
// Rather than reading the whole file, start at the end and work backwards,
|
||||
// stopping when we've found the number of lines we want.
|
||||
|
@ -61,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(file, "File path", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto f = TRY(Core::Stream::File::open_file_or_standard_stream(file, Core::Stream::OpenMode::Read));
|
||||
auto f = TRY(Core::File::open_file_or_standard_stream(file, Core::File::OpenMode::Read));
|
||||
if (!follow)
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!directory.is_empty())
|
||||
TRY(Core::System::chdir(directory));
|
||||
|
||||
NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::Stream::File::open_file_or_standard_stream(archive_file, Core::Stream::OpenMode::Read));
|
||||
NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::File::open_file_or_standard_stream(archive_file, Core::File::OpenMode::Read));
|
||||
|
||||
if (gzip)
|
||||
input_stream = make<Compress::GzipDecompressor>(move(input_stream));
|
||||
|
@ -206,10 +206,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return 1;
|
||||
}
|
||||
|
||||
NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::Stream::File::standard_output());
|
||||
NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::File::standard_output());
|
||||
|
||||
if (!archive_file.is_empty())
|
||||
output_stream = TRY(Core::Stream::File::open(archive_file, Core::Stream::OpenMode::Write));
|
||||
output_stream = TRY(Core::File::open(archive_file, Core::File::OpenMode::Write));
|
||||
|
||||
if (!directory.is_empty())
|
||||
TRY(Core::System::chdir(directory));
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
@ -156,7 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto fn = parse_target_name(type);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
|
||||
auto input = TRY(file->read_until_eof());
|
||||
|
||||
return fn(input.data(), input.size());
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -103,7 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(quiet, "Suppress warnings about cycles", "quiet", 'q');
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read));
|
||||
auto input_bytes = TRY(file->read_until_eof());
|
||||
auto inputs = StringView(input_bytes).split_view_if(is_ascii_space);
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static ErrorOr<void> write_line_content(StringView line, size_t count, bool duplicates_only, bool print_count, Core::Stream::File& outfile)
|
||||
static ErrorOr<void> write_line_content(StringView line, size_t count, bool duplicates_only, bool print_count, Core::File& outfile)
|
||||
{
|
||||
if (duplicates_only && count <= 1)
|
||||
return {};
|
||||
|
@ -79,8 +80,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto infile = TRY(Core::Stream::BufferedFile::create(TRY(Core::Stream::File::open_file_or_standard_stream(inpath, Core::Stream::OpenMode::Read))));
|
||||
auto outfile = TRY(Core::Stream::File::open_file_or_standard_stream(outpath, Core::Stream::OpenMode::Write));
|
||||
auto infile = TRY(Core::BufferedFile::create(TRY(Core::File::open_file_or_standard_stream(inpath, Core::File::OpenMode::Read))));
|
||||
auto outfile = TRY(Core::File::open_file_or_standard_stream(outpath, Core::File::OpenMode::Write));
|
||||
|
||||
size_t count = 0;
|
||||
ByteBuffer previous_buf = TRY(ByteBuffer::create_uninitialized(1024));
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -14,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
{
|
||||
TRY(Core::System::pledge("stdio rpath"));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/sys/kernel/uptime"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/sys/kernel/uptime"sv, Core::File::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/JsonValue.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -42,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
dbgln("Updating utmp from UID={} GID={} EGID={} PID={}", getuid(), getgid(), getegid(), pid);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::ReadWrite));
|
||||
auto file = TRY(Core::File::open("/var/run/utmp"sv, Core::File::OpenMode::ReadWrite));
|
||||
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto previous_json = TRY(JsonValue::from_string(file_contents));
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -25,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open("/var/run/utmp"sv, Core::File::OpenMode::Read));
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
if (!json.is_object()) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibLine/Editor.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -338,7 +339,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!parse_result.has_value())
|
||||
return 1;
|
||||
|
||||
g_stdout = TRY(Core::Stream::File::standard_output());
|
||||
g_stdout = TRY(Core::File::standard_output());
|
||||
g_printer = TRY(try_make<Wasm::Printer>(*g_stdout));
|
||||
|
||||
if (print && !attempt_instantiate) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/URLParser.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibXML/DOM/Document.h>
|
||||
|
@ -371,7 +372,7 @@ static auto parse(StringView contents)
|
|||
if (url.scheme() != "file")
|
||||
return Error::from_string_literal("NYI: Nonlocal entity");
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(url.path(), Core::File::OpenMode::Read));
|
||||
return DeprecatedString::copy(TRY(file->read_until_eof()));
|
||||
},
|
||||
},
|
||||
|
@ -440,7 +441,7 @@ static void do_run_tests(XML::Document& document)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto file_result = Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read);
|
||||
auto file_result = Core::File::open(url.path(), Core::File::OpenMode::Read);
|
||||
if (file_result.is_error()) {
|
||||
warnln("Read error for {}: {}", url.path(), file_result.error());
|
||||
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
||||
|
@ -468,7 +469,7 @@ static void do_run_tests(XML::Document& document)
|
|||
auto out = suite.attributes.find("OUTPUT");
|
||||
if (out != suite.attributes.end()) {
|
||||
auto out_path = LexicalPath::join(test_base_path, out->value).string();
|
||||
auto file_result = Core::Stream::File::open(out_path, Core::Stream::OpenMode::Read);
|
||||
auto file_result = Core::File::open(out_path, Core::File::OpenMode::Read);
|
||||
if (file_result.is_error()) {
|
||||
warnln("Read error for {}: {}", out_path, file_result.error());
|
||||
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
||||
|
@ -516,7 +517,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
parser.parse(arguments);
|
||||
|
||||
s_path = Core::DeprecatedFile::real_path_for(filename);
|
||||
auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(s_path, Core::File::OpenMode::Read));
|
||||
auto contents = TRY(file->read_until_eof());
|
||||
|
||||
auto xml_parser = parse(contents);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCrypto/Checksum/CRC32.h>
|
||||
|
@ -50,12 +51,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
outln("Archive: {}", zip_file_path);
|
||||
auto file_stream = TRY(Core::Stream::File::open(zip_file_path, Core::Stream::OpenMode::Write));
|
||||
auto file_stream = TRY(Core::File::open(zip_file_path, Core::File::OpenMode::Write));
|
||||
Archive::ZipOutputStream zip_stream(move(file_stream));
|
||||
|
||||
auto add_file = [&](DeprecatedString path) -> ErrorOr<void> {
|
||||
auto canonicalized_path = LexicalPath::canonicalized_path(path);
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto file_buffer = TRY(file->read_until_eof());
|
||||
Archive::ZipMember member {};
|
||||
member.name = TRY(String::from_deprecated_string(canonicalized_path));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue