我使用curlftpfs从我的本地网络安装了一个ftp文件夹。
curlftpfs ftp://192。168。100。214/ ftp_mount /
然后我试图在qt程序中迭代该文件夹folder_name_,并在QTableWidget table_每一秒的代码中打印它的内容,就像这样
void Class::PrintContains(QString &directory_name) {
QString absolute_path;
auto directory = QDir(directory_name);
if (directory.entryList(QDir::AllEntries | QDir::NoDotAndDotDot).empty()) {
table_->setCellWidget(0, 0, new QLineEdit("Folder is empty!"));
return;
}
QDirIterator it(directory_name, QDir::AllEntries | QDir::NoDotAndDotDot,
QDirIterator::Subdirectories);
absolute_path = it.path();
int i = 0;
while (it.hasNext()) {
absolute_path = it.next(); // skip directory_name in output
table_->setCellWidget(i++, 0, new QLineEdit(absolute_path));
}
}
void Class::TimerUpdate() {
table_->clearContents();
PrintContains(folder_name_);
}
当与FTP的连接消失时,出现此问题。如果网线拔出,程序挂起。甚至据我所知,整个文件系统挂起直到连接恢复。我如何在我的系统中处理这种行为?
我使用的是20。04。1-Ubuntu c++11,如果这很重要的话