#pragma once #ifndef CRYFS_LIB_IMPL_DIRBLOCK_H_ #define CRYFS_LIB_IMPL_DIRBLOCK_H_ #include #include #include "messmer/cpp-utils/macros.h" #include #include namespace cryfs{ class DirBlock { public: DirBlock(std::unique_ptr block); virtual ~DirBlock(); void InitializeEmptyDir(); std::unique_ptr> GetChildren() const; void AddChild(const std::string &name, const blockstore::Key &blockKey); blockstore::Key GetBlockKeyForName(const std::string &name) const; static bool IsDir(const blockstore::Block &block); private: unsigned char *magicNumber(); 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 *result) const; void assertEnoughSpaceLeft(char *insertPos, size_t insertSize) const; std::unique_ptr _block; DISALLOW_COPY_AND_ASSIGN(DirBlock); }; } #endif