mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:27: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
|
@ -733,7 +733,7 @@ void ImageEditor::save_project()
|
|||
save_project_as();
|
||||
return;
|
||||
}
|
||||
auto response = FileSystemAccessClient::Client::the().request_file(window(), path(), Core::Stream::OpenMode::Truncate | Core::Stream::OpenMode::Write);
|
||||
auto response = FileSystemAccessClient::Client::the().request_file(window(), path(), Core::File::OpenMode::Truncate | Core::File::OpenMode::Write);
|
||||
if (response.is_error())
|
||||
return;
|
||||
auto result = save_project_to_file(response.value().release_stream());
|
||||
|
@ -760,7 +760,7 @@ void ImageEditor::save_project_as()
|
|||
set_unmodified();
|
||||
}
|
||||
|
||||
ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::Stream::File> file) const
|
||||
ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> file) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto json = TRY(JsonObjectSerializer<>::try_create(builder));
|
||||
|
|
|
@ -153,7 +153,7 @@ private:
|
|||
GUI::MouseEvent event_adjusted_for_layer(GUI::MouseEvent const&, Layer const&) const;
|
||||
GUI::MouseEvent event_with_pan_and_scale_applied(GUI::MouseEvent const&) const;
|
||||
|
||||
ErrorOr<void> save_project_to_file(NonnullOwnPtr<Core::Stream::File>) const;
|
||||
ErrorOr<void> save_project_to_file(NonnullOwnPtr<Core::File>) const;
|
||||
|
||||
int calculate_ruler_step_size() const;
|
||||
Gfx::IntRect mouse_indicator_rect_x() const;
|
||||
|
|
|
@ -1288,7 +1288,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
|
|||
if (url.scheme() != "file")
|
||||
continue;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::Stream::OpenMode::Read);
|
||||
auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::File::OpenMode::Read);
|
||||
if (response.is_error())
|
||||
return;
|
||||
open_image(response.release_value());
|
||||
|
|
|
@ -224,11 +224,11 @@ Vector<Color> PaletteWidget::colors()
|
|||
return colors;
|
||||
}
|
||||
|
||||
ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::Stream::File> file)
|
||||
ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::File> file)
|
||||
{
|
||||
Vector<Color> palette;
|
||||
Array<u8, PAGE_SIZE> buffer;
|
||||
auto buffered_file = TRY(Core::Stream::BufferedFile::create(move(file)));
|
||||
auto buffered_file = TRY(Core::BufferedFile::create(move(file)));
|
||||
|
||||
while (TRY(buffered_file->can_read_line())) {
|
||||
auto line = TRY(buffered_file->read_line(buffer));
|
||||
|
@ -252,11 +252,11 @@ ErrorOr<Vector<Color>> PaletteWidget::load_palette_file(NonnullOwnPtr<Core::Stre
|
|||
|
||||
ErrorOr<Vector<Color>> PaletteWidget::load_palette_path(DeprecatedString const& file_path)
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open(file_path, Core::Stream::OpenMode::Read));
|
||||
auto file = TRY(Core::File::open(file_path, Core::File::OpenMode::Read));
|
||||
return load_palette_file(move(file));
|
||||
}
|
||||
|
||||
ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::Stream::File> file)
|
||||
ErrorOr<void> PaletteWidget::save_palette_file(Vector<Color> palette, NonnullOwnPtr<Core::File> file)
|
||||
{
|
||||
for (auto& color : palette) {
|
||||
TRY(file->write_entire_buffer(color.to_deprecated_string_without_alpha().bytes()));
|
||||
|
|
|
@ -31,9 +31,9 @@ public:
|
|||
|
||||
Vector<Color> colors();
|
||||
|
||||
static ErrorOr<Vector<Color>> load_palette_file(NonnullOwnPtr<Core::Stream::File>);
|
||||
static ErrorOr<Vector<Color>> load_palette_file(NonnullOwnPtr<Core::File>);
|
||||
static ErrorOr<Vector<Color>> load_palette_path(DeprecatedString const&);
|
||||
static ErrorOr<void> save_palette_file(Vector<Color>, NonnullOwnPtr<Core::Stream::File>);
|
||||
static ErrorOr<void> save_palette_file(Vector<Color>, NonnullOwnPtr<Core::File>);
|
||||
|
||||
static Vector<Color> fallback_colors();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
ErrorOr<void> ProjectLoader::load_from_file(NonnullOwnPtr<Core::Stream::File> file)
|
||||
ErrorOr<void> ProjectLoader::load_from_file(NonnullOwnPtr<Core::File> file)
|
||||
{
|
||||
auto contents = TRY(file->read_until_eof());
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
ProjectLoader() = default;
|
||||
~ProjectLoader() = default;
|
||||
|
||||
ErrorOr<void> load_from_file(NonnullOwnPtr<Core::Stream::File>);
|
||||
ErrorOr<void> load_from_file(NonnullOwnPtr<Core::File>);
|
||||
|
||||
bool is_raw_image() const { return m_is_raw_image; }
|
||||
bool has_image() const { return !m_image.is_null(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue