小组成员: 曹可心-10223903406 朴祉燕-10224602413
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
639 B

#include "blob_file.h"
#include <fstream>
namespace leveldb {
BlobFile::BlobFile(const std::string& filename) : filename_(filename) {
// 初始化 BlobFile,例如打开文件
}
BlobFile::~BlobFile() {
// 关闭文件
}
Status BlobFile::Put(const Slice& key, const Slice& value) {
std::ofstream file(filename_, std::ios::app | std::ios::binary);
if (!file.is_open()) {
return Status::IOError("Failed to open blob file");
}
// 简单实现,将 key 和 value 写入文件
file.write(key.data(), key.size());
file.write(value.data(), value.size());
file.close();
return Status::OK();
}
} // namespace leveldb