-
Notifications
You must be signed in to change notification settings - Fork 2
/
Block.cc
49 lines (38 loc) · 818 Bytes
/
Block.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* File: Block.cpp
* Author: Tobias Fleig <tobifleig@gmail.com>
*
* Created on August 16, 2015, 3:54 PM
*/
#include "Block.h"
#include <cstdint>
#include <iostream>
#include "StreamUtils.inc"
#include "TimeUtils.inc"
namespace SDI4FS {
Block::Block(STREAM &input) {
read32(input, &id);
if (id == 0) {
std::cout << "fs: error - found block with id zero" << std::endl;
return;
}
read32(input, &lastWriteTime);
}
Block::Block(uint32_t id) {
this->id = id;
}
Block::~Block() {
}
uint32_t Block::getId() {
return id;
}
uint32_t Block::getLastWriteTime() {
return lastWriteTime;
}
void Block::save(STREAM &output) {
// all blocks have: id, lastWriteTime
write32(output, id);
lastWriteTime = now();
write32(output, lastWriteTime);
}
} // SDI4FS