-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOutput.cpp
58 lines (40 loc) · 1.03 KB
/
Output.cpp
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
50
51
52
53
54
55
56
#include "Output.h"
#include <iostream>
#include <fstream>
#include "IOutputStream.h"
void Output::RemoveFile() {
const char *filep = filepath.c_str();
std::remove(filep);
}
Output::Output(std::string _filepath) : filepath(std::move(_filepath)) {
fout.open(filepath, std::ios::binary);
if (!fout.is_open()) {
std::cout << "can't open or create file" << filepath << std::endl;
fout.close();
}
}
Output::Output(const Output & output){
filepath = output.filepath;
fout.open(output.filepath, std::ios::binary);
size = output.size;
if (!fout.is_open()) {
std::cout << "file " << filepath << " cant be open" << std::endl;
fout.close();
}
}
void Output::Write(byte value) {
char buff = (char)value;
fout.write(&buff, sizeof(char));
++size;
}
size_t Output::GetFileSize() {
fout.seekp(0, std::ios::end);
long size_file = fout.tellp();
return size_file;
}
Output::~Output() {
fout.close();
}
std::string Output::GetFilePath(){
return filepath;
}