block manager can now be opened read only or read/write
This commit is contained in:
parent
61293708e3
commit
8999232657
2
block.h
2
block.h
@ -39,7 +39,7 @@ namespace persistent_data {
|
||||
public:
|
||||
typedef boost::shared_ptr<block_manager> ptr;
|
||||
|
||||
block_manager(std::string const &path, block_address nr_blocks);
|
||||
block_manager(std::string const &path, block_address nr_blocks, bool writeable = false);
|
||||
~block_manager();
|
||||
|
||||
typedef unsigned char buffer[BlockSize];
|
||||
|
@ -51,14 +51,13 @@ block_manager<BlockSize>::write_ref::data()
|
||||
//----------------------------------------------------------------
|
||||
|
||||
template <uint32_t BlockSize>
|
||||
block_manager<BlockSize>::block_manager(std::string const &path, block_address nr_blocks)
|
||||
block_manager<BlockSize>::block_manager(std::string const &path, block_address nr_blocks, bool writeable)
|
||||
: nr_blocks_(nr_blocks),
|
||||
lock_count_(0),
|
||||
superblock_count_(0),
|
||||
ordinary_count_(0)
|
||||
{
|
||||
//fd_ = ::open(path.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
fd_ = ::open(path.c_str(), O_RDONLY, 0666);
|
||||
fd_ = ::open(path.c_str(), writeable ? (O_RDWR | O_CREAT) : O_RDONLY, 0666);
|
||||
if (fd_ < 0)
|
||||
throw std::runtime_error("couldn't open file");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user