added replacement of \ and / in filenames from RsLinks

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5978 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-12-13 22:13:58 +00:00
parent bf3194f035
commit 892057b53e
2 changed files with 18 additions and 4 deletions

View file

@ -1060,7 +1060,17 @@ static void processList(const QStringList &list, const QString &textSingular, co
srcIds.push_back((*it).peerId) ; srcIds.push_back((*it).peerId) ;
} }
if (rsFiles->FileRequest(link.name().toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) { QString cleanname = link.name() ;
bool bad_chars = false ;
for(uint32_t i=0;i<cleanname.length();++i)
if(cleanname[i] == '/' || cleanname[i] == '\\')
{
cleanname[i] = '_';
flag |= RSLINK_PROCESS_NOTIFY_BAD_CHARS ;
}
if (rsFiles->FileRequest(cleanname.toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
fileAdded.append(link.name()); fileAdded.append(link.name());
} else { } else {
fileExist.append(link.name()); fileExist.append(link.name());
@ -1337,6 +1347,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
result += QString("<br>%1: %2").arg(QObject::tr("Invalid links")).arg(countInvalid); result += QString("<br>%1: %2").arg(QObject::tr("Invalid links")).arg(countInvalid);
} }
} }
if(flag & RSLINK_PROCESS_NOTIFY_BAD_CHARS)
result += QString("<br>%1").arg(QObject::tr("Warning: '/' and '\\' characters in some of the\nabove filenames will be replaced by '_'.")) ;
if (result.isEmpty() == false) { if (result.isEmpty() == false) {
QMessageBox mb(QObject::tr("Result"), "<html><body>" + result + "</body></html>", QMessageBox::Information, QMessageBox::Ok, 0, 0); QMessageBox mb(QObject::tr("Result"), "<html><body>" + result + "</body></html>", QMessageBox::Information, QMessageBox::Ok, 0, 0);
@ -1344,6 +1356,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
mb.exec(); mb.exec();
} }
return 0; return 0;
} }

View file

@ -40,6 +40,7 @@
#define RSLINK_PROCESS_NOTIFY_SUCCESS 1 // notify on success #define RSLINK_PROCESS_NOTIFY_SUCCESS 1 // notify on success
#define RSLINK_PROCESS_NOTIFY_ERROR 2 // notify on error #define RSLINK_PROCESS_NOTIFY_ERROR 2 // notify on error
#define RSLINK_PROCESS_NOTIFY_ASK 4 // ask for add the links #define RSLINK_PROCESS_NOTIFY_ASK 4 // ask for add the links
#define RSLINK_PROCESS_NOTIFY_BAD_CHARS 8 // / or \\ characters in a filename
#define RSLINK_PROCESS_NOTIFY_ALL -1 #define RSLINK_PROCESS_NOTIFY_ALL -1