libcryfs/src/cryfs_lib/impl/DirBlock.h

45 lines
1.1 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_
2014-12-09 17:19:59 +01:00
#include <blockstore/interface/Block.h>
#include "fspp/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;
2014-12-09 17:19:59 +01:00
void AddChild(const std::string &name, const std::string &blockKey);
std::string 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