Send error messages/warnings to /dev/stderr using std::cerr
This commit is contained in:
parent
c4adc3b4dc
commit
e97b4496c8
20
mcopy.cpp
20
mcopy.cpp
|
@ -51,7 +51,7 @@ void getMetadataFromFile(std::string format, std::string str) {
|
||||||
TagLib::Tag *tag = file.tag();
|
TagLib::Tag *tag = file.tag();
|
||||||
|
|
||||||
if (file.isNull() || !file.audioProperties()) {
|
if (file.isNull() || !file.audioProperties()) {
|
||||||
std::cout << "File '" << str << "' is not valid. Skipping.\n";
|
std::cerr << "File '" << str << "' is not valid. Skipping.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,28 +67,28 @@ void getMetadataFromFile(std::string format, std::string str) {
|
||||||
title = "Unknown";
|
title = "Unknown";
|
||||||
|
|
||||||
if (ask) {
|
if (ask) {
|
||||||
std::cout << "mcopy: Could not retrieve title; please specify\n> ";
|
std::cerr << "mcopy: Could not retrieve title; please specify\n> ";
|
||||||
std::getline(std::cin, title);
|
std::getline(std::cin, title);
|
||||||
}
|
}
|
||||||
} else if (album.empty()) {
|
} else if (album.empty()) {
|
||||||
album = "Unknown";
|
album = "Unknown";
|
||||||
|
|
||||||
if (ask) {
|
if (ask) {
|
||||||
std::cout << "mcopy: Could not retrieve album; please specify\n> ";
|
std::cerr << "mcopy: Could not retrieve album; please specify\n> ";
|
||||||
std::getline(std::cin, album);
|
std::getline(std::cin, album);
|
||||||
}
|
}
|
||||||
} else if (artist.empty()) {
|
} else if (artist.empty()) {
|
||||||
artist = "Unknown";
|
artist = "Unknown";
|
||||||
|
|
||||||
if (ask) {
|
if (ask) {
|
||||||
std::cout << "mcopy: Could not retrieve artist; please specify\n> ";
|
std::cerr << "mcopy: Could not retrieve artist; please specify\n> ";
|
||||||
std::getline(std::cin, artist);
|
std::getline(std::cin, artist);
|
||||||
}
|
}
|
||||||
} else if (track.empty()) {
|
} else if (track.empty()) {
|
||||||
track = "Unknown";
|
track = "Unknown";
|
||||||
|
|
||||||
if (ask) {
|
if (ask) {
|
||||||
std::cout << "mcopy: Could not retrieve track; please specify\n> ";
|
std::cerr << "mcopy: Could not retrieve track; please specify\n> ";
|
||||||
std::getline(std::cin, track);
|
std::getline(std::cin, track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ void getMetadataFromFile(std::string format, std::string str) {
|
||||||
std::ifstream ef(filename);
|
std::ifstream ef(filename);
|
||||||
|
|
||||||
if (static_cast<bool>(ef.good())) {
|
if (static_cast<bool>(ef.good())) {
|
||||||
std::cout << "mcopy: File already exists, skipping.\n";
|
std::cerr << "mcopy: File already exists, skipping.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ void getMetadataFromFile(std::string format, std::string str) {
|
||||||
std::filesystem::create_directories(dir);
|
std::filesystem::create_directories(dir);
|
||||||
|
|
||||||
if (!std::filesystem::copy_file(str, filename)) {
|
if (!std::filesystem::copy_file(str, filename)) {
|
||||||
std::cout << "mcopy: Failed to copy file " << str << " to " << filename << "\n";
|
std::cerr << "mcopy: Failed to copy file " << str << " to " << filename << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
std::cout << "mcopy: Copied file " << str << " to " << filename << "\n";
|
std::cout << "mcopy: Copied file " << str << " to " << filename << "\n";
|
||||||
|
@ -148,12 +148,12 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!format.compare("")) {
|
if (!format.compare("")) {
|
||||||
std::cout << "mcopy: You must specify a format.\n";
|
std::cerr << "mcopy: You must specify a format.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
std::cout << "mcopy: You must specify a file to copy.\n";
|
std::cerr << "mcopy: You must specify a file to copy.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!set) {
|
if (!set) {
|
||||||
std::cout << "mcopy: File not found.\n";
|
std::cerr << "mcopy: File not found.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue