Fix bug where no error message was displayed if an mtp device couldn't be found.

This commit is contained in:
Jason Ferrara 2012-05-09 21:49:30 +00:00
parent c90b86b9b7
commit ae1ddf0aa4

View File

@ -402,6 +402,30 @@ int main(int argc, char *argv[])
}
else
{
bool foundDevice = 0;
ConnectedMtpDevices devices;
if (devices.NumDevices()==0)
{
std::cerr << "No mtp devices found." << std::endl;
return -1;
}
for(int i = 0; i<devices.NumDevices(); i++)
{
ConnectedDeviceInfo devInfo = devices.GetDeviceInfo(i);
if (((devInfo.bus_location == requestedBusLocation) &&
(devInfo.devnum == requestedDevnum)) ||
(requestedBusLocation == -1) || (requestedDevnum == -1))
{
foundDevice = true;
break;
}
}
if (!foundDevice)
{
std::cerr << "Requested device not found" << std::endl;
return -1;
}
cache = std::unique_ptr<MtpMetadataCache>(new MtpMetadataCache);
metadataCache = cache.get();
}