-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompressedFileWriter.cpp
More file actions
45 lines (34 loc) · 1.04 KB
/
Copy pathCompressedFileWriter.cpp
File metadata and controls
45 lines (34 loc) · 1.04 KB
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
/*
* CompressedFileWriter.cpp
*
* Created on: 14/05/2014
* Author: ari
*/
#include "CompressedFileWriter.h"
#include <stdint.h>
namespace std {
CompressedFileWriter::CompressedFileWriter() {
// TODO Auto-generated constructor stub
}
CompressedFileWriter::CompressedFileWriter(string path) {
this->fileStream.open(path.c_str(), ios::out | ios::binary);
}
void CompressedFileWriter::writeBlockHeader(uint32_t size){
// Esto es una chanchada, pero no se me ocurre otra forma.
// La idea es leer 32 bits de a 8, para poder escribirlos
char * aux = (char *) &size;
this->fileStream.write(aux,4);
}
void CompressedFileWriter::writeBlock(DataBlock* block) {
uint32_t sizeInBits = block->getSizeInBits();
vector<unsigned char>::iterator it = block->getIterator();
this->writeBlockHeader(sizeInBits);
this->fileStream.write((char*)&(it[0]),block->getSizeInBytes());
}
void CompressedFileWriter::close() {
this->fileStream.close();
}
CompressedFileWriter::~CompressedFileWriter() {
// TODO Auto-generated destructor stub
}
} /* namespace std */