Allow creating files
This commit is contained in:
parent
79455cf01f
commit
ebc70cff53
@ -30,14 +30,21 @@ CryDir::~CryDir() {
|
||||
}
|
||||
|
||||
unique_ptr<fspp::File> CryDir::createFile(const string &name, mode_t mode) {
|
||||
throw FuseErrnoException(ENOTSUP);
|
||||
auto child = _device->CreateBlob(0);
|
||||
_blob->AddChild(name, child.key);
|
||||
//TODO Di we need a return value in createDir for fspp? If not, change fspp!
|
||||
auto fileblob = make_unique<FileBlob>(std::move(child.blob));
|
||||
fileblob->InitializeEmptyFile();
|
||||
return make_unique<CryFile>(std::move(fileblob));
|
||||
}
|
||||
|
||||
unique_ptr<fspp::Dir> CryDir::createDir(const string &name, mode_t mode) {
|
||||
auto child = _device->CreateBlob(CryDevice::DIR_BLOBSIZE);
|
||||
_blob->AddChild(name, child.key);
|
||||
//TODO I don't think we need a return value in createDir for fspp. Change fspp!
|
||||
return make_unique<CryDir>(_device, make_unique<DirBlob>(std::move(child.blob)));
|
||||
auto dirblob = make_unique<DirBlob>(std::move(child.blob));
|
||||
dirblob->InitializeEmptyDir();
|
||||
return make_unique<CryDir>(_device, std::move(dirblob));
|
||||
}
|
||||
|
||||
void CryDir::rmdir() {
|
||||
|
@ -14,6 +14,14 @@ FileBlob::FileBlob(unique_ptr<Blob> blob)
|
||||
FileBlob::~FileBlob() {
|
||||
}
|
||||
|
||||
void FileBlob::InitializeEmptyFile() {
|
||||
*magicNumber() = MagicNumbers::FILE;
|
||||
}
|
||||
|
||||
unsigned char *FileBlob::magicNumber() {
|
||||
return const_cast<unsigned char*>(magicNumber(const_cast<const Blob&>(*_blob)));
|
||||
}
|
||||
|
||||
const unsigned char *FileBlob::magicNumber(const blobstore::Blob &blob) {
|
||||
return (unsigned char*)blob.data();
|
||||
}
|
||||
|
@ -15,9 +15,12 @@ public:
|
||||
|
||||
static bool IsFile(const blobstore::Blob &blob);
|
||||
|
||||
void InitializeEmptyFile();
|
||||
|
||||
private:
|
||||
std::unique_ptr<blobstore::Blob> _blob;
|
||||
|
||||
unsigned char *magicNumber();
|
||||
static const unsigned char *magicNumber(const blobstore::Blob &blob);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user