-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransfer.cpp
33 lines (32 loc) · 1.12 KB
/
transfer.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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
int main(int argc, char *argv[]) {
std::vector<std::string> arguments(argv, argv + argc);
for (int i = 1; i < arguments.size(); i++) {
std::string file_name = arguments[i];
std::ifstream infile;
std::ofstream outfile;
infile.open(file_name, std::ios::binary);
if(file_name.substr(file_name.size() - 3) != ".uc") {
std::cerr << "The file " << file_name << "is not a .uc file!" << std::endl;
return 1;
}
if(!infile.is_open()) {
std::cerr << "Error opening input file which name is " << file_name << std::endl;
return 1;
}
std::string output_file_name = file_name.substr(0,file_name.size() - 2) + "mp3";
outfile.open(output_file_name, std::ios::binary);
char byte;
while(infile.get(byte)) {
byte ^= 0xa3;
outfile << byte;
}
infile.close();
outfile.close();
std::cout << file_name << "already transfered to " << output_file_name << std::endl;
}
return 0;
}