fix error message when no raw device found

This commit is contained in:
Peter Hatina 2012-09-29 13:03:17 +02:00
parent 7498f340f3
commit 2d11b4726e
4 changed files with 11 additions and 9 deletions

View File

@ -72,7 +72,7 @@ public:
bool parseOptions(int argc, char **argv);
void printHelp() const;
void printVersion() const;
void listDevices() { m_device.listDevices(); }
bool listDevices() { return m_device.listDevices(); }
bool exec();
bool isGood() const { return m_options.m_good; }

View File

@ -39,10 +39,8 @@ int main(int argc, char **argv)
return 0;
}
if (filesystem->isListDevices()) {
filesystem->listDevices();
return 0;
}
if (filesystem->isListDevices())
return !filesystem->listDevices();
return !filesystem->exec();
}

View File

@ -107,19 +107,23 @@ void MTPDevice::disconnect()
logmsg("Disconnected.\n");
}
void MTPDevice::listDevices()
bool MTPDevice::listDevices()
{
int raw_devices_cnt;
LIBMTP_raw_device_t *raw_devices;
LIBMTP_error_number_t err = LIBMTP_Detect_Raw_Devices(
&raw_devices, &raw_devices_cnt);
if (err != 0)
return;
if (err != 0) {
if (err == LIBMTP_ERROR_NO_DEVICE_ATTACHED)
std::cerr << "No raw devices found.\n";
return false;
}
for (int i = 0; i < raw_devices_cnt; ++i) {
std::cout << i + 1 << ": " << raw_devices[i].device_entry.vendor
<< raw_devices[i].device_entry.product << "\n";
}
return true;
}
uint64_t MTPDevice::storageTotalSize() const

View File

@ -37,7 +37,7 @@ public:
bool connect(int dev_no = 0);
void disconnect();
void listDevices();
bool listDevices();
void enableMove(bool e = true) { m_move_enabled = e; }
uint64_t storageTotalSize() const;