|
|
|
|
|
|
|
|
// This file implements the common functionality for the configuration
|
|
|
// This file implements the common functionality for the configuration
|
|
|
// utilities.
|
|
|
// utilities.
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
#include <cerrno>
|
|
|
#include <cerrno>
|
|
|
#include <cstring>
|
|
|
#include <cstring>
|
|
|
#include <cstdio>
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
|
throw std::runtime_error(Temp);
|
|
|
throw std::runtime_error(Temp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!Input.eof()) { // Copy if there are characters.
|
|
|
|
|
|
// Copying an empty file causes
|
|
|
|
|
|
Output << Input.rdbuf(); // failbit to be set.
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Output << Input.rdbuf();
|
|
|
|
|
|
|
|
|
if (Output.bad() || Output.fail()) {
|
|
|
|
|
|
|
|
|
if (Output.bad()) { // Copying an empty file causes
|
|
|
|
|
|
// failbit to be set.
|
|
|
std::string Temp;
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
|
Temp = "Error copying " + From;
|
|
|
Temp = "Error copying " + From;
|
|
|
|
|
|
|
|
|
Temp += ": ";
|
|
|
Temp += ": ";
|
|
|
Temp += strerror(errno);
|
|
|
Temp += strerror(errno);
|
|
|
throw std::runtime_error(Temp);
|
|
|
throw std::runtime_error(Temp);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Input.close();
|
|
|
Input.close();
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Output.close();
|
|
|
Output.close();
|
|
|
if (!Output) {
|
|
|
|
|
|
|
|
|
if (Output.bad()) {
|
|
|
std::string Temp;
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
|
Temp = "Error closing the file " + To;
|
|
|
Temp = "Error closing the file " + To;
|