2015-02-27 00:51:51 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef CRYFS_LIB_IMPL_DIRBLOB_H_
|
|
|
|
#define CRYFS_LIB_IMPL_DIRBLOB_H_
|
|
|
|
|
|
|
|
#include <messmer/blobstore/interface/Blob.h>
|
|
|
|
#include <messmer/blockstore/utils/Key.h>
|
|
|
|
#include "messmer/cpp-utils/macros.h"
|
2015-03-10 21:51:42 +01:00
|
|
|
#include <messmer/fspp/fs_interface/Dir.h>
|
2015-02-27 00:51:51 +01:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace cryfs{
|
|
|
|
|
|
|
|
class DirBlob {
|
|
|
|
public:
|
|
|
|
DirBlob(std::unique_ptr<blobstore::Blob> blob);
|
|
|
|
virtual ~DirBlob();
|
|
|
|
|
|
|
|
void InitializeEmptyDir();
|
2015-03-10 21:51:42 +01:00
|
|
|
std::unique_ptr<std::vector<fspp::Dir::Entry>> GetChildren() const;
|
|
|
|
void AddChildDir(const std::string &name, const blockstore::Key &blobKey);
|
|
|
|
void AddChildFile(const std::string &name, const blockstore::Key &blobKey);
|
2015-02-27 00:51:51 +01:00
|
|
|
blockstore::Key GetBlobKeyForName(const std::string &name) const;
|
|
|
|
|
|
|
|
static bool IsDir(const blobstore::Blob &blob);
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned char magicNumber() const;
|
|
|
|
static const unsigned char magicNumber(const blobstore::Blob &blob);
|
|
|
|
|
2015-03-10 21:51:42 +01:00
|
|
|
void AddChild(const std::string &name, const blockstore::Key &blobKey, fspp::Dir::EntryType type);
|
|
|
|
|
|
|
|
const char *readAndAddNextChild(const char *pos, std::vector<fspp::Dir::Entry> *result) const;
|
2015-02-27 00:51:51 +01:00
|
|
|
|
|
|
|
std::unique_ptr<blobstore::Blob> _blob;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DirBlob);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|