mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:47:35 +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
|
@ -232,7 +232,7 @@ void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hov
|
|||
}
|
||||
|
||||
dbgln_if(EDITOR_DEBUG, "opening {}", it->value);
|
||||
auto file_or_error = Core::Stream::File::open(it->value, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(it->value, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
dbgln("Failed to open {}, {}", it->value, file_or_error.error());
|
||||
return;
|
||||
|
|
|
@ -155,7 +155,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback)
|
|||
void GitWidget::show_diff(DeprecatedString const& file_path)
|
||||
{
|
||||
if (!m_git_repo->is_tracked(file_path)) {
|
||||
auto file = Core::Stream::File::open(file_path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
|
||||
auto file = Core::File::open(file_path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
|
||||
auto content = file->read_until_eof().release_value_but_fixme_should_propagate_errors();
|
||||
m_view_diff_callback("", Diff::generate_only_additions(content));
|
||||
return;
|
||||
|
|
|
@ -550,7 +550,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(Dep
|
|||
|
||||
filepath = DeprecatedString::formatted("{}{}", filepath, filename);
|
||||
|
||||
auto file_or_error = Core::Stream::File::open(filepath, Core::Stream::OpenMode::Write | Core::Stream::OpenMode::MustBeNew);
|
||||
auto file_or_error = Core::File::open(filepath, Core::File::OpenMode::Write | Core::File::OpenMode::MustBeNew);
|
||||
if (file_or_error.is_error()) {
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to create '{}': {}", filepath, file_or_error.error()));
|
||||
return;
|
||||
|
@ -1791,7 +1791,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config
|
|||
if (maybe_error.is_error() && maybe_error.error().code() != EEXIST)
|
||||
return maybe_error.release_error();
|
||||
|
||||
auto file = TRY(Core::Stream::File::open(absolute_config_file_path, Core::Stream::OpenMode::Write));
|
||||
auto file = TRY(Core::File::open(absolute_config_file_path, Core::File::OpenMode::Write));
|
||||
TRY(file->write_entire_buffer(
|
||||
"{\n"
|
||||
" \"build_command\": \"your build command here\",\n"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibCore/File.h>
|
||||
|
||||
namespace LanguageServers {
|
||||
|
||||
|
@ -74,13 +75,13 @@ DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) cons
|
|||
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(DeprecatedString const& filename) const
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open(to_absolute_path(filename), Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(to_absolute_path(filename), Core::File::OpenMode::Read));
|
||||
return create_from_file(move(file));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_fd(int fd) const
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::adopt_fd(fd, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::adopt_fd(fd, Core::File::OpenMode::Read));
|
||||
return create_from_file(move(file));
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ public:
|
|||
};
|
||||
static DefaultDocumentClient s_default_document_client;
|
||||
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr<Core::Stream::File> file) const
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr<Core::File> file) const
|
||||
{
|
||||
auto content = TRY(file->read_until_eof());
|
||||
auto document = GUI::TextDocument::create(&s_default_document_client);
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
private:
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(DeprecatedString const& filename) const;
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_fd(int fd) const;
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::Stream::File>) const;
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::File>) const;
|
||||
static RefPtr<GUI::TextDocument> create_with_content(DeprecatedString const&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -112,7 +112,7 @@ ErrorOr<void> ProjectBuilder::build_serenity_component()
|
|||
|
||||
ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_path)
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open(cmake_file_path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Read));
|
||||
auto content = TRY(file->read_until_eof());
|
||||
|
||||
static Regex<ECMA262> const component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~");
|
||||
|
@ -135,7 +135,7 @@ ErrorOr<void> ProjectBuilder::initialize_build_directory()
|
|||
if (Core::DeprecatedFile::exists(cmake_file_path))
|
||||
MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed));
|
||||
|
||||
auto cmake_file = TRY(Core::Stream::File::open(cmake_file_path, Core::Stream::OpenMode::Write));
|
||||
auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write));
|
||||
TRY(cmake_file->write_entire_buffer(generate_cmake_file_content().bytes()));
|
||||
|
||||
TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "ProjectConfig.h"
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
namespace HackStudio {
|
||||
|
@ -17,7 +18,7 @@ ProjectConfig::ProjectConfig(JsonObject config)
|
|||
|
||||
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(DeprecatedString 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_contents = TRY(file->read_until_eof());
|
||||
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "ProjectFile.h"
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
namespace HackStudio {
|
||||
|
@ -54,7 +55,7 @@ void ProjectFile::create_document_if_needed() const
|
|||
return;
|
||||
|
||||
m_document = CodeDocument::create(m_name);
|
||||
auto file_or_error = Core::Stream::File::open(m_name, Core::Stream::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(m_name, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Couldn't open '{}': {}", m_name, file_or_error.error());
|
||||
// This is okay though, we'll just go with an empty document and create the file when saving.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue