summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCore/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibCore/MappedFile.cpp67
-rw-r--r--Userland/Libraries/LibCore/MappedFile.h40
-rw-r--r--Userland/Libraries/LibCoredump/Backtrace.cpp4
-rw-r--r--Userland/Libraries/LibCoredump/Backtrace.h4
-rw-r--r--Userland/Libraries/LibCoredump/Inspector.cpp2
-rw-r--r--Userland/Libraries/LibCoredump/Reader.cpp7
-rw-r--r--Userland/Libraries/LibCoredump/Reader.h8
-rw-r--r--Userland/Libraries/LibDebug/DebugSession.cpp2
-rw-r--r--Userland/Libraries/LibDebug/DebugSession.h2
-rw-r--r--Userland/Libraries/LibDebug/LoadedLibrary.h6
-rw-r--r--Userland/Libraries/LibGUI/FileIconProvider.cpp4
-rw-r--r--Userland/Libraries/LibGUI/ImageWidget.cpp4
-rw-r--r--Userland/Libraries/LibGfx/Bitmap.cpp4
-rw-r--r--Userland/Libraries/LibGfx/BitmapFont.cpp2
-rw-r--r--Userland/Libraries/LibGfx/BitmapFont.h4
-rw-r--r--Userland/Libraries/LibGfx/Font.h2
-rw-r--r--Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp4
-rw-r--r--Userland/Libraries/LibGfx/TrueTypeFont/Font.h2
-rw-r--r--Userland/Libraries/LibPCIDB/Database.cpp2
-rw-r--r--Userland/Libraries/LibPCIDB/Database.h6
-rw-r--r--Userland/Libraries/LibSymbolication/Symbolication.cpp6
-rw-r--r--Userland/Libraries/LibUSBDB/Database.cpp2
-rw-r--r--Userland/Libraries/LibUSBDB/Database.h6
-rw-r--r--Userland/Libraries/LibVideo/MatroskaReader.cpp4
25 files changed, 151 insertions, 44 deletions
diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt
index b90062a5c0..d3e415e517 100644
--- a/Userland/Libraries/LibCore/CMakeLists.txt
+++ b/Userland/Libraries/LibCore/CMakeLists.txt
@@ -16,6 +16,7 @@ set(SOURCES
LocalServer.cpp
LocalSocket.cpp
LockFile.cpp
+ MappedFile.cpp
MimeData.cpp
NetworkJob.cpp
NetworkResponse.cpp
diff --git a/Userland/Libraries/LibCore/MappedFile.cpp b/Userland/Libraries/LibCore/MappedFile.cpp
new file mode 100644
index 0000000000..fc98c43834
--- /dev/null
+++ b/Userland/Libraries/LibCore/MappedFile.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/ScopeGuard.h>
+#include <AK/String.h>
+#include <LibCore/MappedFile.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+namespace Core {
+
+ErrorOr<NonnullRefPtr<MappedFile>> MappedFile::map(String const& path)
+{
+ int fd = open(path.characters(), O_RDONLY | O_CLOEXEC, 0);
+ if (fd < 0)
+ return Error::from_errno(errno);
+
+ return map_from_fd_and_close(fd, path);
+}
+
+ErrorOr<NonnullRefPtr<MappedFile>> MappedFile::map_from_fd_and_close(int fd, [[maybe_unused]] String const& path)
+{
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
+ return Error::from_errno(errno);
+
+ ScopeGuard fd_close_guard = [fd] {
+ close(fd);
+ };
+
+ struct stat st;
+ if (fstat(fd, &st) < 0)
+ return Error::from_errno(errno);
+
+ auto size = st.st_size;
+ auto* ptr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);
+
+ if (ptr == MAP_FAILED)
+ return Error::from_errno(errno);
+
+#ifdef __serenity__
+ if (set_mmap_name(ptr, size, path.characters()) < 0) {
+ perror("set_mmap_name");
+ }
+#endif
+
+ return adopt_ref(*new MappedFile(ptr, size));
+}
+
+MappedFile::MappedFile(void* ptr, size_t size)
+ : m_data(ptr)
+ , m_size(size)
+{
+}
+
+MappedFile::~MappedFile()
+{
+ auto rc = munmap(m_data, m_size);
+ VERIFY(rc == 0);
+}
+
+}
diff --git a/Userland/Libraries/LibCore/MappedFile.h b/Userland/Libraries/LibCore/MappedFile.h
new file mode 100644
index 0000000000..7048caf995
--- /dev/null
+++ b/Userland/Libraries/LibCore/MappedFile.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Error.h>
+#include <AK/Noncopyable.h>
+#include <AK/NonnullRefPtr.h>
+#include <AK/RefCounted.h>
+#include <AK/Result.h>
+
+namespace Core {
+
+class MappedFile : public RefCounted<MappedFile> {
+ AK_MAKE_NONCOPYABLE(MappedFile);
+ AK_MAKE_NONMOVABLE(MappedFile);
+
+public:
+ static ErrorOr<NonnullRefPtr<MappedFile>> map(String const& path);
+ static ErrorOr<NonnullRefPtr<MappedFile>> map_from_fd_and_close(int fd, String const& path);
+ ~MappedFile();
+
+ void* data() { return m_data; }
+ const void* data() const { return m_data; }
+
+ size_t size() const { return m_size; }
+
+ ReadonlyBytes bytes() const { return { m_data, m_size }; }
+
+private:
+ explicit MappedFile(void*, size_t);
+
+ void* m_data { nullptr };
+ size_t m_size { 0 };
+};
+
+}
diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp
index a0f9969d42..03d3e2238a 100644
--- a/Userland/Libraries/LibCoredump/Backtrace.cpp
+++ b/Userland/Libraries/LibCoredump/Backtrace.cpp
@@ -5,11 +5,11 @@
*/
#include <AK/LexicalPath.h>
-#include <AK/MappedFile.h>
#include <AK/Platform.h>
#include <AK/StringBuilder.h>
#include <AK/Types.h>
#include <LibCore/File.h>
+#include <LibCore/MappedFile.h>
#include <LibCoredump/Backtrace.h>
#include <LibCoredump/Reader.h>
#include <LibELF/Core.h>
@@ -30,7 +30,7 @@ ELFObjectInfo const* Backtrace::object_info_for_region(ELF::Core::MemoryRegionIn
if (!Core::File::exists(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;
diff --git a/Userland/Libraries/LibCoredump/Backtrace.h b/Userland/Libraries/LibCoredump/Backtrace.h
index a8a300bd62..cd4586155f 100644
--- a/Userland/Libraries/LibCoredump/Backtrace.h
+++ b/Userland/Libraries/LibCoredump/Backtrace.h
@@ -14,14 +14,14 @@
namespace Coredump {
struct ELFObjectInfo {
- ELFObjectInfo(NonnullRefPtr<MappedFile> file, NonnullOwnPtr<Debug::DebugInfo>&& debug_info, NonnullOwnPtr<ELF::Image> image)
+ ELFObjectInfo(NonnullRefPtr<Core::MappedFile> file, NonnullOwnPtr<Debug::DebugInfo>&& debug_info, NonnullOwnPtr<ELF::Image> image)
: file(move(file))
, debug_info(move(debug_info))
, image(move(image))
{
}
- NonnullRefPtr<MappedFile> file;
+ NonnullRefPtr<Core::MappedFile> file;
NonnullOwnPtr<Debug::DebugInfo> debug_info;
NonnullOwnPtr<ELF::Image> image;
};
diff --git a/Userland/Libraries/LibCoredump/Inspector.cpp b/Userland/Libraries/LibCoredump/Inspector.cpp
index d5b7935bc8..4eb3614332 100644
--- a/Userland/Libraries/LibCoredump/Inspector.cpp
+++ b/Userland/Libraries/LibCoredump/Inspector.cpp
@@ -41,7 +41,7 @@ void Inspector::parse_loaded_libraries(Function<void(float)> on_progress)
if (on_progress)
on_progress(library_index / (float)number_of_libraries);
- auto file_or_error = MappedFile::map(library.path);
+ auto file_or_error = Core::MappedFile::map(library.path);
if (file_or_error.is_error())
return;
diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp
index db5ed3f60a..30273b13ed 100644
--- a/Userland/Libraries/LibCoredump/Reader.cpp
+++ b/Userland/Libraries/LibCoredump/Reader.cpp
@@ -17,7 +17,7 @@ namespace Coredump {
OwnPtr<Reader> Reader::create(StringView path)
{
- auto file_or_error = MappedFile::map(path);
+ auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error())
return {};
@@ -38,7 +38,7 @@ Reader::Reader(ByteBuffer buffer)
m_coredump_buffer = move(buffer);
}
-Reader::Reader(NonnullRefPtr<MappedFile> file)
+Reader::Reader(NonnullRefPtr<Core::MappedFile> file)
: Reader(file->bytes())
{
m_mapped_file = move(file);
@@ -261,7 +261,6 @@ HashMap<String, String> Reader::metadata() const
struct LibraryData {
String name;
- OwnPtr<MappedFile> file;
ELF::Image lib_elf;
};
@@ -282,7 +281,7 @@ const Reader::LibraryData* Reader::library_containing(FlatPtr address) const
}
if (!cached_libs.contains(path)) {
- auto file_or_error = MappedFile::map(path);
+ auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error())
return {};
auto image = ELF::Image(file_or_error.value()->bytes());
diff --git a/Userland/Libraries/LibCoredump/Reader.h b/Userland/Libraries/LibCoredump/Reader.h
index b6241ba754..915c586553 100644
--- a/Userland/Libraries/LibCoredump/Reader.h
+++ b/Userland/Libraries/LibCoredump/Reader.h
@@ -7,9 +7,9 @@
#pragma once
#include <AK/HashMap.h>
-#include <AK/MappedFile.h>
#include <AK/Noncopyable.h>
#include <AK/OwnPtr.h>
+#include <LibCore/MappedFile.h>
#include <LibELF/Core.h>
#include <LibELF/Image.h>
@@ -46,7 +46,7 @@ public:
struct LibraryData {
String name;
FlatPtr base_address { 0 };
- NonnullRefPtr<MappedFile> file;
+ NonnullRefPtr<Core::MappedFile> file;
ELF::Image lib_elf;
};
const LibraryData* library_containing(FlatPtr address) const;
@@ -61,7 +61,7 @@ public:
private:
explicit Reader(ReadonlyBytes);
explicit Reader(ByteBuffer);
- explicit Reader(NonnullRefPtr<MappedFile>);
+ explicit Reader(NonnullRefPtr<Core::MappedFile>);
static Optional<ByteBuffer> decompress_coredump(ReadonlyBytes);
@@ -86,7 +86,7 @@ private:
const JsonObject process_info() const;
// For uncompressed coredumps, we keep the MappedFile
- RefPtr<MappedFile> m_mapped_file;
+ RefPtr<Core::MappedFile> m_mapped_file;
// For compressed coredumps, we decompress them into a ByteBuffer
ByteBuffer m_coredump_buffer;
diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp
index 41b579dacf..487132c2d2 100644
--- a/Userland/Libraries/LibDebug/DebugSession.cpp
+++ b/Userland/Libraries/LibDebug/DebugSession.cpp
@@ -452,7 +452,7 @@ void DebugSession::update_loaded_libs()
return IterationDecision::Continue;
}
- auto file_or_error = MappedFile::map(object_path.value());
+ auto file_or_error = Core::MappedFile::map(object_path.value());
if (file_or_error.is_error())
return IterationDecision::Continue;
diff --git a/Userland/Libraries/LibDebug/DebugSession.h b/Userland/Libraries/LibDebug/DebugSession.h
index 43f05fb67f..0949ca47f7 100644
--- a/Userland/Libraries/LibDebug/DebugSession.h
+++ b/Userland/Libraries/LibDebug/DebugSession.h
@@ -8,12 +8,12 @@
#include <AK/Demangle.h>
#include <AK/HashMap.h>
-#include <AK/MappedFile.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <LibC/sys/arch/i386/regs.h>
+#include <LibCore/MappedFile.h>
#include <LibDebug/DebugInfo.h>
#include <LibDebug/ProcessInspector.h>
#include <signal.h>
diff --git a/Userland/Libraries/LibDebug/LoadedLibrary.h b/Userland/Libraries/LibDebug/LoadedLibrary.h
index 15141bae88..2eb29f15c7 100644
--- a/Userland/Libraries/LibDebug/LoadedLibrary.h
+++ b/Userland/Libraries/LibDebug/LoadedLibrary.h
@@ -7,19 +7,19 @@
#pragma once
#include "DebugInfo.h"
-#include <AK/MappedFile.h>
#include <AK/Types.h>
+#include <LibCore/MappedFile.h>
#include <LibELF/Image.h>
namespace Debug {
struct LoadedLibrary {
String name;
- NonnullRefPtr<MappedFile> file;
+ NonnullRefPtr<Core::MappedFile> file;
NonnullOwnPtr<ELF::Image> image;
NonnullOwnPtr<DebugInfo> debug_info;
FlatPtr base_address {};
- LoadedLibrary(String const& name, NonnullRefPtr<MappedFile> file, NonnullOwnPtr<ELF::Image> image, NonnullOwnPtr<DebugInfo>&& debug_info, FlatPtr base_address)
+ LoadedLibrary(String const& name, NonnullRefPtr<Core::MappedFile> file, NonnullOwnPtr<ELF::Image> image, NonnullOwnPtr<DebugInfo>&& debug_info, FlatPtr base_address)
: name(name)
, file(move(file))
, image(move(image))
diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp
index 90eafe9404..8b2c14c778 100644
--- a/Userland/Libraries/LibGUI/FileIconProvider.cpp
+++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp
@@ -5,10 +5,10 @@
*/
#include <AK/LexicalPath.h>
-#include <AK/MappedFile.h>
#include <AK/String.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
+#include <LibCore/MappedFile.h>
#include <LibCore/StandardPaths.h>
#include <LibELF/Image.h>
#include <LibGUI/FileIconProvider.h>
@@ -147,7 +147,7 @@ Icon FileIconProvider::icon_for_executable(const String& path)
// If the icon for an app isn't in the cache we attempt to load the file as an ELF image and extract
// the serenity_app_icon_* sections which should contain the icons as raw PNG data. In the future it would
// be better if the binary signalled the image format being used or we deduced it, e.g. using magic bytes.
- auto file_or_error = MappedFile::map(path);
+ auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error()) {
app_icon_cache.set(path, s_executable_icon);
return s_executable_icon;
diff --git a/Userland/Libraries/LibGUI/ImageWidget.cpp b/Userland/Libraries/LibGUI/ImageWidget.cpp
index 03cc58e271..b28ee605a2 100644
--- a/Userland/Libraries/LibGUI/ImageWidget.cpp
+++ b/Userland/Libraries/LibGUI/ImageWidget.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/MappedFile.h>
+#include <LibCore/MappedFile.h>
#include <LibGUI/ImageWidget.h>
#include <LibGUI/Painter.h>
#include <LibGfx/Bitmap.h>
@@ -73,7 +73,7 @@ void ImageWidget::animate()
void ImageWidget::load_from_file(StringView path)
{
- auto file_or_error = MappedFile::map(path);
+ auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error())
return;
diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp
index 06f2afe419..32ff60175c 100644
--- a/Userland/Libraries/LibGfx/Bitmap.cpp
+++ b/Userland/Libraries/LibGfx/Bitmap.cpp
@@ -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)
diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp
index a3c6dc06ea..c7db009236 100644
--- a/Userland/Libraries/LibGfx/BitmapFont.cpp
+++ b/Userland/Libraries/LibGfx/BitmapFont.cpp
@@ -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;
diff --git a/Userland/Libraries/LibGfx/BitmapFont.h b/Userland/Libraries/LibGfx/BitmapFont.h
index 5734fe64ec..6adb4858c1 100644
--- a/Userland/Libraries/LibGfx/BitmapFont.h
+++ b/Userland/Libraries/LibGfx/BitmapFont.h
@@ -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 };
diff --git a/Userland/Libraries/LibGfx/Font.h b/Userland/Libraries/LibGfx/Font.h
index f622724846..32facfa1f9 100644
--- a/Userland/Libraries/LibGfx/Font.h
+++ b/Userland/Libraries/LibGfx/Font.h
@@ -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>
diff --git a/Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp b/Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp
index 6f5beddb8f..fe7e0b02e7 100644
--- a/Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp
+++ b/Userland/Libraries/LibGfx/TrueTypeFont/Font.cpp
@@ -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;
diff --git a/Userland/Libraries/LibGfx/TrueTypeFont/Font.h b/Userland/Libraries/LibGfx/TrueTypeFont/Font.h
index a5cb528d04..3f4341d850 100644
--- a/Userland/Libraries/LibGfx/TrueTypeFont/Font.h
+++ b/Userland/Libraries/LibGfx/TrueTypeFont/Font.h
@@ -87,7 +87,7 @@ private:
{
}
- RefPtr<MappedFile> m_mapped_file;
+ RefPtr<Core::MappedFile> m_mapped_file;
ReadonlyBytes m_buffer;
diff --git a/Userland/Libraries/LibPCIDB/Database.cpp b/Userland/Libraries/LibPCIDB/Database.cpp
index 4282afd84c..ce23b80994 100644
--- a/Userland/Libraries/LibPCIDB/Database.cpp
+++ b/Userland/Libraries/LibPCIDB/Database.cpp
@@ -14,7 +14,7 @@ namespace PCIDB {
RefPtr<Database> Database::open(const String& filename)
{
- auto file_or_error = MappedFile::map(filename);
+ auto file_or_error = Core::MappedFile::map(filename);
if (file_or_error.is_error())
return nullptr;
auto res = adopt_ref(*new Database(file_or_error.release_value()));
diff --git a/Userland/Libraries/LibPCIDB/Database.h b/Userland/Libraries/LibPCIDB/Database.h
index 01a0073c8d..7577f55898 100644
--- a/Userland/Libraries/LibPCIDB/Database.h
+++ b/Userland/Libraries/LibPCIDB/Database.h
@@ -7,12 +7,12 @@
#pragma once
#include <AK/HashMap.h>
-#include <AK/MappedFile.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/StringView.h>
+#include <LibCore/MappedFile.h>
namespace PCIDB {
@@ -64,7 +64,7 @@ public:
const StringView get_programming_interface(u8 class_id, u8 subclass_id, u8 programming_interface_id) const;
private:
- explicit Database(NonnullRefPtr<MappedFile> file)
+ explicit Database(NonnullRefPtr<Core::MappedFile> file)
: m_file(move(file))
{
}
@@ -77,7 +77,7 @@ private:
ClassMode,
};
- NonnullRefPtr<MappedFile> m_file;
+ NonnullRefPtr<Core::MappedFile> m_file;
StringView m_view {};
HashMap<int, NonnullOwnPtr<Vendor>> m_vendors;
HashMap<int, NonnullOwnPtr<Class>> m_classes;
diff --git a/Userland/Libraries/LibSymbolication/Symbolication.cpp b/Userland/Libraries/LibSymbolication/Symbolication.cpp
index 3484958218..42852a0fb6 100644
--- a/Userland/Libraries/LibSymbolication/Symbolication.cpp
+++ b/Userland/Libraries/LibSymbolication/Symbolication.cpp
@@ -10,15 +10,15 @@
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <AK/LexicalPath.h>
-#include <AK/MappedFile.h>
#include <LibCore/File.h>
+#include <LibCore/MappedFile.h>
#include <LibDebug/DebugInfo.h>
#include <LibSymbolication/Symbolication.h>
namespace Symbolication {
struct CachedELF {
- NonnullRefPtr<MappedFile> mapped_file;
+ NonnullRefPtr<Core::MappedFile> mapped_file;
NonnullOwnPtr<Debug::DebugInfo> debug_info;
NonnullOwnPtr<ELF::Image> image;
};
@@ -81,7 +81,7 @@ Optional<Symbol> symbolicate(String const& path, FlatPtr address, IncludeSourceP
}
}
if (!s_cache.contains(full_path)) {
- auto mapped_file = MappedFile::map(full_path);
+ auto mapped_file = Core::MappedFile::map(full_path);
if (mapped_file.is_error()) {
dbgln("Failed to map {}: {}", full_path, mapped_file.error());
s_cache.set(full_path, {});
diff --git a/Userland/Libraries/LibUSBDB/Database.cpp b/Userland/Libraries/LibUSBDB/Database.cpp
index e42a0fa03f..140ca5bb65 100644
--- a/Userland/Libraries/LibUSBDB/Database.cpp
+++ b/Userland/Libraries/LibUSBDB/Database.cpp
@@ -14,7 +14,7 @@ namespace USBDB {
RefPtr<Database> Database::open(const String& filename)
{
- auto file_or_error = MappedFile::map(filename);
+ auto file_or_error = Core::MappedFile::map(filename);
if (file_or_error.is_error())
return nullptr;
auto res = adopt_ref(*new Database(file_or_error.release_value()));
diff --git a/Userland/Libraries/LibUSBDB/Database.h b/Userland/Libraries/LibUSBDB/Database.h
index c1fa0cc9f1..207fedcc1e 100644
--- a/Userland/Libraries/LibUSBDB/Database.h
+++ b/Userland/Libraries/LibUSBDB/Database.h
@@ -7,12 +7,12 @@
#pragma once
#include <AK/HashMap.h>
-#include <AK/MappedFile.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/StringView.h>
+#include <LibCore/MappedFile.h>
namespace USBDB {
@@ -63,7 +63,7 @@ public:
const StringView get_protocol(u8 class_id, u8 subclass_id, u8 protocol_id) const;
private:
- explicit Database(NonnullRefPtr<MappedFile> file)
+ explicit Database(NonnullRefPtr<Core::MappedFile> file)
: m_file(move(file))
{
}
@@ -76,7 +76,7 @@ private:
ClassMode,
};
- NonnullRefPtr<MappedFile> m_file;
+ NonnullRefPtr<Core::MappedFile> m_file;
StringView m_view {};
HashMap<int, NonnullOwnPtr<Vendor>> m_vendors;
HashMap<int, NonnullOwnPtr<Class>> m_classes;
diff --git a/Userland/Libraries/LibVideo/MatroskaReader.cpp b/Userland/Libraries/LibVideo/MatroskaReader.cpp
index f7c0ddce14..ae51adb1fa 100644
--- a/Userland/Libraries/LibVideo/MatroskaReader.cpp
+++ b/Userland/Libraries/LibVideo/MatroskaReader.cpp
@@ -6,9 +6,9 @@
#include "MatroskaReader.h"
#include <AK/Function.h>
-#include <AK/MappedFile.h>
#include <AK/Optional.h>
#include <AK/Utf8View.h>
+#include <LibCore/MappedFile.h>
namespace Video {
@@ -43,7 +43,7 @@ constexpr u32 TIMESTAMP_ID = 0xE7;
OwnPtr<MatroskaDocument> MatroskaReader::parse_matroska_from_file(StringView path)
{
- auto mapped_file_result = MappedFile::map(path);
+ auto mapped_file_result = Core::MappedFile::map(path);
if (mapped_file_result.is_error())
return {};