Skip to content
Snippets Groups Projects
Commit 5ac080b2 authored by Rom Walton's avatar Rom Walton
Browse files

VBOX: Tighten up how the version information is displayed on systems falling back to vboxmanage.

parent 11923759
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@ using std::string;
#if defined(_MSC_VER)
#define getcwd _getcwd
#define stricmp _stricmp
#define snprintf _snprintf
#endif
#include "diagnostics.h"
......@@ -1471,7 +1472,9 @@ int VBOX_VM::get_install_directory(string& install_directory) {
int VBOX_VM::get_version_information(string& version) {
string command;
string output;
int vbox_major = 0, vbox_minor = 0, vbox_release = 0;
int retval;
char buf[256];
// Record the VirtualBox version information for later use.
command = "--version ";
......@@ -1487,7 +1490,17 @@ int VBOX_VM::get_version_information(string& version) {
++iter;
}
}
version = string("VirtualBox VboxManage Interface (Version: ") + output + string(")");
if (3 == sscanf(output.c_str(), "%d.%d.%d", &vbox_major, &vbox_minor, &vbox_release)) {
snprintf(
buf, sizeof(buf),
"VirtualBox VboxManage Interface (Version: %d.%d.%d)",
vbox_major, vbox_minor, vbox_release
);
version = buf;
} else {
version = "VirtualBox VboxManage Interface (Version: Unknown)";
}
}
return retval;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment