summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Boric <jblbeurope@gmail.com>2021-05-15 12:38:40 +0200
committerLinus Groh <mail@linusgroh.de>2021-05-17 18:14:05 +0100
commitd0eb376520db8fc2f95547f272fe4727f247d0fa (patch)
treeb997e56f20d481fed36a013bf7eca89fe8de876d
parent3038edab00f4aa112a8ec78114be232174e84078 (diff)
downloadserenity-d0eb376520db8fc2f95547f272fe4727f247d0fa.zip
LibArchive: Move method implementations away from header
-rw-r--r--Userland/Libraries/LibArchive/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibArchive/Tar.cpp33
-rw-r--r--Userland/Libraries/LibArchive/Tar.h20
3 files changed, 34 insertions, 20 deletions
diff --git a/Userland/Libraries/LibArchive/CMakeLists.txt b/Userland/Libraries/LibArchive/CMakeLists.txt
index b6fef50a50..98ffaffb6b 100644
--- a/Userland/Libraries/LibArchive/CMakeLists.txt
+++ b/Userland/Libraries/LibArchive/CMakeLists.txt
@@ -1,4 +1,5 @@
set(SOURCES
+ Tar.cpp
TarStream.cpp
Zip.cpp
)
diff --git a/Userland/Libraries/LibArchive/Tar.cpp b/Userland/Libraries/LibArchive/Tar.cpp
new file mode 100644
index 0000000000..47626ed93d
--- /dev/null
+++ b/Userland/Libraries/LibArchive/Tar.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2020, Peter Elliott <pelliott@ualberta.ca>
+ * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include "Tar.h"
+
+namespace Archive {
+
+unsigned TarFileHeader::expected_checksum() const
+{
+ auto checksum = 0u;
+ const u8* u8_this = reinterpret_cast<const u8*>(this);
+ const u8* u8_m_checksum = reinterpret_cast<const u8*>(&m_checksum);
+ for (auto i = 0u; i < sizeof(TarFileHeader); ++i) {
+ if (u8_this + i >= u8_m_checksum && u8_this + i < u8_m_checksum + sizeof(m_checksum)) {
+ checksum += ' ';
+ } else {
+ checksum += u8_this[i];
+ }
+ }
+ return checksum;
+}
+
+void TarFileHeader::calculate_checksum()
+{
+ memset(m_checksum, ' ', sizeof(m_checksum));
+ VERIFY(String::formatted("{:06o}", expected_checksum()).copy_characters_to_buffer(m_checksum, sizeof(m_checksum)));
+}
+
+}
diff --git a/Userland/Libraries/LibArchive/Tar.h b/Userland/Libraries/LibArchive/Tar.h
index de3118b983..8e05ce11a7 100644
--- a/Userland/Libraries/LibArchive/Tar.h
+++ b/Userland/Libraries/LibArchive/Tar.h
@@ -113,24 +113,4 @@ size_t TarFileHeader::get_tar_field(const char (&field)[N])
return value;
}
-unsigned TarFileHeader::expected_checksum() const
-{
- auto checksum = 0u;
- const u8* u8_this = reinterpret_cast<const u8*>(this);
- const u8* u8_m_checksum = reinterpret_cast<const u8*>(&m_checksum);
- for (auto i = 0u; i < sizeof(TarFileHeader); ++i) {
- if (u8_this + i >= u8_m_checksum && u8_this + i < u8_m_checksum + sizeof(m_checksum)) {
- checksum += ' ';
- } else {
- checksum += u8_this[i];
- }
- }
- return checksum;
-}
-
-void TarFileHeader::calculate_checksum()
-{
- memset(m_checksum, ' ', sizeof(m_checksum));
- VERIFY(String::formatted("{:06o}", expected_checksum()).copy_characters_to_buffer(m_checksum, sizeof(m_checksum)));
-}
}