-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction.cpp
More file actions
41 lines (37 loc) · 1.18 KB
/
Function.cpp
File metadata and controls
41 lines (37 loc) · 1.18 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
#include "iostream"
#include "QFile"
#include "vector"
#include "QDebug"
#include "Function.h"
using namespace std;
void merge_file_json(QString path){
path.remove(".json");
vector <QFile*> file;
for(int i=0; QFile::exists(path+QString::number(i)+".json"); i++){
file.push_back(new QFile);
file.back()->setFileName(path+QString::number(i)+".json");
}
if(file.size()>1){
QFile outFile("out_json.json");
if(outFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)){
for(int i=0; i<file.size(); i++){
file[i]->open(QIODevice::WriteOnly);
QTextStream stream(file[i]);
QString str = stream.readAll();
if((i+1)!=file.size()){//если файл не последний
str.chop(1);
}
else if(i){//если файл не первый
str.remove(0, 1);
}
stream<<str;
file[i]->close();
}
}
}
else{
qDebug()<<"Error\n";
}
}
//void merge_file_csv(QString &path){
//}