mirror of
https://github.com/phatina/simple-mtpfs
synced 2025-03-09 22:58:55 +00:00
add error messages in SMTPFileSystem
This commit is contained in:
parent
55f7586e6a
commit
01c28b1e53
@ -289,6 +289,7 @@ bool SMTPFileSystem::parseOptions(int argc, char **argv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
logerr("Wrong usage.\n");
|
||||||
m_options.m_good = false;
|
m_options.m_good = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -306,11 +307,13 @@ bool SMTPFileSystem::parseOptions(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (--m_options.m_device_no < 0) {
|
if (--m_options.m_device_no < 0) {
|
||||||
|
logerr("Device number must be positive number greater than 0.\n");
|
||||||
m_options.m_good = false;
|
m_options.m_good = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_options.m_mount_point) {
|
if (!m_options.m_mount_point) {
|
||||||
|
logerr("Mount point missing.\n");
|
||||||
m_options.m_good = false;
|
m_options.m_good = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -380,27 +383,36 @@ bool SMTPFileSystem::exec()
|
|||||||
if (m_options.m_version || m_options.m_help)
|
if (m_options.m_version || m_options.m_help)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!smtpfs_check_dir(m_options.m_mount_point))
|
if (!smtpfs_check_dir(m_options.m_mount_point)) {
|
||||||
|
logerr("Can not mount the device to '", m_options.m_mount_point, "'.\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!createTmpDir())
|
if (!createTmpDir()) {
|
||||||
|
logerr("Can not create a temporary directory.\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBUSB1
|
#ifdef HAVE_LIBUSB1
|
||||||
if (m_options.m_device_file) {
|
if (m_options.m_device_file) {
|
||||||
// Try to use device file first, if provided
|
// Try to use device file first, if provided
|
||||||
if (!m_device.connect(m_options.m_device_file))
|
if (!m_device.connect(m_options.m_device_file)) {
|
||||||
|
logerr("Can not connect to device '", m_options.m_device_file, "'.\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif // HAVE_LIBUSB1
|
#endif // HAVE_LIBUSB1
|
||||||
{
|
{
|
||||||
// Connect to MTP device by order number, if no device file supplied
|
// Connect to MTP device by order number, if no device file supplied
|
||||||
if (!m_device.connect(m_options.m_device_no))
|
if (!m_device.connect(m_options.m_device_no)) {
|
||||||
|
logerr("Can not connect to device no. ", m_options.m_device_no, ".\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_device.enableMove(m_options.m_enable_move);
|
m_device.enableMove(m_options.m_enable_move);
|
||||||
if (fuse_main(m_args.argc, m_args.argv, &m_fuse_operations, nullptr) > 0)
|
if (fuse_main(m_args.argc, m_args.argv, &m_fuse_operations, nullptr) > 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
m_device.disconnect();
|
m_device.disconnect();
|
||||||
|
|
||||||
removeTmpDir();
|
removeTmpDir();
|
||||||
|
Loading…
Reference in New Issue
Block a user