fix error message when no raw device found
This commit is contained in:
parent
7498f340f3
commit
2d11b4726e
|
@ -72,7 +72,7 @@ public:
|
||||||
bool parseOptions(int argc, char **argv);
|
bool parseOptions(int argc, char **argv);
|
||||||
void printHelp() const;
|
void printHelp() const;
|
||||||
void printVersion() const;
|
void printVersion() const;
|
||||||
void listDevices() { m_device.listDevices(); }
|
bool listDevices() { return m_device.listDevices(); }
|
||||||
|
|
||||||
bool exec();
|
bool exec();
|
||||||
bool isGood() const { return m_options.m_good; }
|
bool isGood() const { return m_options.m_good; }
|
||||||
|
|
|
@ -39,10 +39,8 @@ int main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filesystem->isListDevices()) {
|
if (filesystem->isListDevices())
|
||||||
filesystem->listDevices();
|
return !filesystem->listDevices();
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !filesystem->exec();
|
return !filesystem->exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,19 +107,23 @@ void MTPDevice::disconnect()
|
||||||
logmsg("Disconnected.\n");
|
logmsg("Disconnected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTPDevice::listDevices()
|
bool MTPDevice::listDevices()
|
||||||
{
|
{
|
||||||
int raw_devices_cnt;
|
int raw_devices_cnt;
|
||||||
LIBMTP_raw_device_t *raw_devices;
|
LIBMTP_raw_device_t *raw_devices;
|
||||||
LIBMTP_error_number_t err = LIBMTP_Detect_Raw_Devices(
|
LIBMTP_error_number_t err = LIBMTP_Detect_Raw_Devices(
|
||||||
&raw_devices, &raw_devices_cnt);
|
&raw_devices, &raw_devices_cnt);
|
||||||
if (err != 0)
|
if (err != 0) {
|
||||||
return;
|
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) {
|
for (int i = 0; i < raw_devices_cnt; ++i) {
|
||||||
std::cout << i + 1 << ": " << raw_devices[i].device_entry.vendor
|
std::cout << i + 1 << ": " << raw_devices[i].device_entry.vendor
|
||||||
<< raw_devices[i].device_entry.product << "\n";
|
<< raw_devices[i].device_entry.product << "\n";
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MTPDevice::storageTotalSize() const
|
uint64_t MTPDevice::storageTotalSize() const
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
bool connect(int dev_no = 0);
|
bool connect(int dev_no = 0);
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
void listDevices();
|
bool listDevices();
|
||||||
void enableMove(bool e = true) { m_move_enabled = e; }
|
void enableMove(bool e = true) { m_move_enabled = e; }
|
||||||
|
|
||||||
uint64_t storageTotalSize() const;
|
uint64_t storageTotalSize() const;
|
||||||
|
|
Loading…
Reference in New Issue