libcryfs/impl/DirBlock.h

46 lines
1.2 KiB
C
Raw Normal View History

#pragma once
2014-12-09 17:19:59 +01:00
#ifndef CRYFS_LIB_IMPL_DIRBLOCK_H_
#define CRYFS_LIB_IMPL_DIRBLOCK_H_
2015-02-17 01:02:15 +01:00
#include <messmer/blockstore/interface/Block.h>
#include <messmer/blockstore/utils/Key.h>
#include "messmer/cpp-utils/macros.h"
#include <memory>
#include <vector>
namespace cryfs{
2014-12-09 17:19:59 +01:00
class DirBlock {
public:
2014-12-09 17:19:59 +01:00
DirBlock(std::unique_ptr<blockstore::Block> block);
virtual ~DirBlock();
void InitializeEmptyDir();
std::unique_ptr<std::vector<std::string>> GetChildren() const;
void AddChild(const std::string &name, const blockstore::Key &blockKey);
blockstore::Key GetBlockKeyForName(const std::string &name) const;
2014-12-09 17:19:59 +01:00
static bool IsDir(const blockstore::Block &block);
2014-12-09 11:13:50 +01:00
private:
2014-12-09 11:13:50 +01:00
unsigned char *magicNumber();
2014-12-09 17:19:59 +01:00
static const unsigned char *magicNumber(const blockstore::Block &block);
unsigned int *entryCounter();
const unsigned int *entryCounter() const;
char *entriesBegin();
const char *entriesBegin() const;
char *entriesEnd();
const char *readAndAddNextChild(const char *pos, std::vector<std::string> *result) const;
void assertEnoughSpaceLeft(char *insertPos, size_t insertSize) const;
2014-12-09 17:19:59 +01:00
std::unique_ptr<blockstore::Block> _block;
2014-12-09 17:19:59 +01:00
DISALLOW_COPY_AND_ASSIGN(DirBlock);
};
}
#endif