-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconv.cpp
More file actions
42 lines (29 loc) · 1.02 KB
/
Copy pathconv.cpp
File metadata and controls
42 lines (29 loc) · 1.02 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
#include <iostream>
#include <fstream>
#include <vector>
void convertDatToSegy(const std::string& datFile, const std::string& segyFile) {
/
std::ifstream datStream(datFile, std::ios::binary);
if (!datStream.is_open()) {
std::cerr << "Erro ao abrir o arquivo .dat" << std::endl;
return;
}
std::vector<char> data((std::istreambuf_iterator<char>(datStream)), std::istreambuf_iterator<char>());
datStream.close();
std::ofstream segyStream(segyFile, std::ios::binary);
if (!segyStream.is_open()) {
std::cerr << "Erro ao abrir o arquivo .SEGY" << std::endl;
return;
}
char segyHeader[3200] = {0};
segyStream.write(segyHeader, sizeof(segyHeader));
segyStream.write(data.data(), data.size());
segyStream.close();
std::cout << "Conversão concluída com sucesso!" << std::endl;
}
int main() {
std::string datFile = "input.dat";
std::string segyFile = "output.segy";
convertDatToSegy(datFile, segyFile);
return 0;
}