mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:37:45 +00:00
LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK (which is supposed to be user/kernel agnostic.)
This commit is contained in:
parent
c1c9da6c35
commit
58fb3ebf66
48 changed files with 101 additions and 103 deletions
|
@ -6,13 +6,13 @@
|
|||
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/Memory.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Try.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/ImageDecoder.h>
|
||||
#include <LibGfx/ShareableBitmap.h>
|
||||
|
@ -134,7 +134,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_load_from_file(String const& path, in
|
|||
|
||||
ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_load_from_fd_and_close(int fd, String const& path)
|
||||
{
|
||||
auto file = TRY(MappedFile::map_from_fd_and_close(fd, path));
|
||||
auto file = TRY(Core::MappedFile::map_from_fd_and_close(fd, path));
|
||||
if (auto decoder = ImageDecoder::try_create(file->bytes())) {
|
||||
auto frame = TRY(decoder->frame(0));
|
||||
if (auto& bitmap = frame.image)
|
||||
|
|
|
@ -202,7 +202,7 @@ RefPtr<BitmapFont> BitmapFont::load_from_file(String const& path)
|
|||
if (Core::File::is_device(path))
|
||||
return nullptr;
|
||||
|
||||
auto file_or_error = MappedFile::map(path);
|
||||
auto file_or_error = Core::MappedFile::map(path);
|
||||
if (file_or_error.is_error())
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/Font.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
|
@ -128,7 +128,7 @@ private:
|
|||
|
||||
u8* m_rows { nullptr };
|
||||
u8* m_glyph_widths { nullptr };
|
||||
RefPtr<MappedFile> m_mapped_file;
|
||||
RefPtr<Core::MappedFile> m_mapped_file;
|
||||
|
||||
u8 m_glyph_width { 0 };
|
||||
u8 m_glyph_height { 0 };
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
#include <AK/Bitmap.h>
|
||||
#include <AK/ByteReader.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/Try.h>
|
||||
#include <AK/Utf32View.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/TrueTypeFont/Cmap.h>
|
||||
#include <LibGfx/TrueTypeFont/Font.h>
|
||||
#include <LibGfx/TrueTypeFont/Glyf.h>
|
||||
|
@ -227,7 +227,7 @@ GlyphHorizontalMetrics Hmtx::get_glyph_horizontal_metrics(u32 glyph_id) const
|
|||
|
||||
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_file(String path, unsigned index)
|
||||
{
|
||||
auto file = TRY(MappedFile::map(path));
|
||||
auto file = TRY(Core::MappedFile::map(path));
|
||||
auto font = TRY(try_load_from_externally_owned_memory(file->bytes(), index));
|
||||
font->m_mapped_file = move(file);
|
||||
return font;
|
||||
|
|
|
@ -87,7 +87,7 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<MappedFile> m_mapped_file;
|
||||
RefPtr<Core::MappedFile> m_mapped_file;
|
||||
|
||||
ReadonlyBytes m_buffer;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue