store: add old repository code to build
This commit is contained in:
parent
3367faf2b8
commit
f4aab7f2c2
@ -32,6 +32,10 @@ add_library(libemory
|
||||
emory/fs/ostream.hpp
|
||||
emory/fs/xattr.cpp
|
||||
emory/fs/xattr.hpp
|
||||
emory/store/bits.cpp
|
||||
emory/store/bits.hpp
|
||||
emory/store/repo.cpp
|
||||
emory/store/repo.hpp
|
||||
)
|
||||
|
||||
target_link_libraries(libemory cruft acl)
|
||||
|
13
emory/store/bits.cpp
Normal file
13
emory/store/bits.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#include "bits.hpp"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
67
emory/store/bits.hpp
Normal file
67
emory/store/bits.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cruft/util/std.hpp>
|
||||
#include <cruft/crypto/hash/sha1.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace emory::store::bits {
|
||||
constexpr std::array<u08, 8> MAGIC { 'e', 'r', '0', '0', 0x0d, 0x0a, 0x1a, 0x00, };
|
||||
|
||||
struct [[gnu::packed]] header {
|
||||
u08 magic[8];
|
||||
u64 version;
|
||||
struct [[gnu::packed]] {
|
||||
u64 types;
|
||||
u64 records;
|
||||
} entries;
|
||||
};
|
||||
|
||||
bool is_valid (header const&) noexcept;
|
||||
|
||||
|
||||
struct [[gnu::packed]] type {
|
||||
u16 system;
|
||||
u16 index;
|
||||
u08 count;
|
||||
u08 length;
|
||||
u16 reserved;
|
||||
};
|
||||
|
||||
|
||||
namespace record {
|
||||
struct data {
|
||||
cruft::crypto::hash::SHA1::digest_t digest;
|
||||
u64 first;
|
||||
u64 last;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
constexpr u16 EMORY = 0x0000;
|
||||
constexpr u16 POSIX = 0x0001;
|
||||
|
||||
constexpr type DATA {
|
||||
.system = EMORY,
|
||||
.index = 0x0001,
|
||||
.count = 0,
|
||||
.length = sizeof (record::data),
|
||||
.reserved = 0,
|
||||
};
|
||||
|
||||
constexpr type PATH {
|
||||
.system = POSIX,
|
||||
.index = 0x0001,
|
||||
.count = 0,
|
||||
.length = 0,
|
||||
.reserved = 0,
|
||||
};
|
||||
};
|
15
emory/store/repo.cpp
Normal file
15
emory/store/repo.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#include "repo.hpp"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
struct chunker {
|
||||
|
||||
};
|
59
emory/store/repo.hpp
Normal file
59
emory/store/repo.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bits.hpp"
|
||||
|
||||
#include <cruft/util/io.hpp>
|
||||
|
||||
namespace emory::store {
|
||||
struct repo {
|
||||
repo (cruft::mapped_file &&src);
|
||||
|
||||
cruft::view<bits::type const*> types (void) const;
|
||||
|
||||
struct record_iterator {
|
||||
using iterator_tag = std::input_iterator_tag;
|
||||
using value_type = std::pair<bits::type const&, void*>;
|
||||
|
||||
record_iterator (
|
||||
cruft::view<bits::type const*> _types,
|
||||
cruft::view<u08 const*> _data
|
||||
);
|
||||
|
||||
value_type operator* (void) const;
|
||||
|
||||
record_iterator& operator++ ();
|
||||
|
||||
bool operator== (record_iterator const&) const noexcept;
|
||||
bool operator!= (record_iterator const&) const noexcept;
|
||||
|
||||
private:
|
||||
cruft::view<bits::type const*> m_types;
|
||||
cruft::view<u08 const*> m_data;
|
||||
};
|
||||
|
||||
private:
|
||||
cruft::mapped_file m_src;
|
||||
};
|
||||
|
||||
|
||||
struct serialiser {
|
||||
virtual ~serialiser ();
|
||||
|
||||
virtual bits::type type (void) const;
|
||||
virtual u64 write (cruft::posix::fd &dst, cruft::posix::fd &src);
|
||||
virtual std::ostream& describe (std::ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
u64 send (cruft::posix::fd &dst, cruft::posix::fd &src);
|
||||
|
||||
std::ostream& operator<< (std::ostream&, serialiser const&);
|
||||
}
|
Loading…
Reference in New Issue
Block a user