Updated error handling

This commit is contained in:
Uwe Seimet 2021-09-15 16:33:50 +02:00
parent c78ff8fce1
commit 7f68f9b91f
2 changed files with 11 additions and 2 deletions

View File

@ -61,8 +61,7 @@ enum PbOperation {
RESERVE = 14;
// Create an image file. The image file must not yet exist.
// PbCommand.params(0) contains the filename, PbCommand.params(1) contains the file size in bytes.
// PbCommand.params(2) is optional (default is false) and controls the file permissions.
// If "true" (case-insensitive) a read-only file is created.
// PbCommand.params(2) controls the file permissions. If "true" (case-insensitive) a read-only file is created.
// The filename is relative to the default image folder and must not contain a slash.
// The file size must be a multiple of 512.
CREATE_IMAGE = 15;

View File

@ -216,6 +216,12 @@ void CommandCreateImage(const string&hostname, int port, const string& image_par
command.add_params(image_params.substr(0, separatorPos));
command.add_params(image_params.substr(separatorPos + 1));
}
else {
cerr << "Error: Invalid file description '" << image_params << "', format is NAME:SIZE" << endl;
exit(EXIT_FAILURE);
}
command.add_params("false");
PbResult result;
SendCommand(hostname.c_str(), port, command, result);
@ -242,6 +248,10 @@ void CommandRenameImage(const string&hostname, int port, const string& image_par
command.add_params(image_params.substr(0, separatorPos));
command.add_params(image_params.substr(separatorPos + 1));
}
else {
cerr << "Error: Invalid file description '" << image_params << "', format is OLD_NAME:NEW_NAME" << endl;
exit(EXIT_FAILURE);
}
PbResult result;
SendCommand(hostname.c_str(), port, command, result);