Use std::exit() instead of C exit() function

This commit is contained in:
Jacob 2023-08-16 22:49:06 +02:00
parent 17b614a278
commit 74fe842445

View file

@ -115,7 +115,7 @@ void getMetadataFromFile(std::string format, std::string str) {
if (!std::filesystem::copy_file(str, filename)) {
std::cerr << "mcopy: Failed to copy file " << str << " to " << filename << "\n";
exit(1);
std::exit(1);
} else if (!quiet) {
std::cout << "mcopy: Copied file " << str << " to " << filename << "\n";
}
@ -132,10 +132,10 @@ int main(int argc, char **argv) {
if (!arg.compare("-h") || !arg.compare("--help")) {
help();
exit(0);
std::exit(0);
} else if (!arg.compare("-v") || !arg.compare("--version")) {
std::cout << "mcopy " << VERSION << '\n';
exit(0);
std::exit(0);
} else if (!arg.compare("-a") || !arg.compare("--ask")) {
ask = true;
} else if (!arg.compare("-na") || !arg.compare("--no-ask")) {
@ -154,12 +154,12 @@ int main(int argc, char **argv) {
if (!format.compare("")) {
std::cerr << "mcopy: You must specify a format.\n";
exit(1);
std::exit(1);
}
if (argc < 4) {
std::cerr << "mcopy: You must specify a file to copy.\n";
exit(1);
std::exit(1);
}
int set{0};
@ -175,6 +175,6 @@ int main(int argc, char **argv) {
if (!set) {
std::cerr << "mcopy: File not found.\n";
exit(1);
std::exit(1);
}
}