/** Parses the list of command-line arguments for their argument names and * values. */ void Rshare::parseArguments(QStringList args, bool firstRun) { QString arg, value; /* Loop through all command-line args/values and put them in a map */ for (int i = 0; i < args.size(); ++i) { /* Get the argument name and set a blank value */ arg = args.at(i);//.toLower(); Need Upper case for file name. if (arg.toLower() == "empty") continue; value = ""; /* Check if it starts with a - or -- */ if (arg.startsWith("-")) { arg = arg.mid((arg.startsWith("--") ? 2 : 1)); /* Check if it takes a value and there is one on the command-line */ if (i < args.size()-1 && argNeedsValue(arg.toLower())) { value = args.at(++i); } } else { /* Check if links or files without arg */ if (arg.toLower().startsWith("retroshare://")) { value = arg; arg = ARG_RSLINK_L; } else { if (QFile(arg).exists()) { value = arg; arg = ARG_RSFILE_L; } } } /* Don't send theses argument to _args map to allow multiple. */ if (arg == ARG_RSLINK_S || arg == ARG_RSLINK_L) { _links.append(value); } else if (arg == ARG_RSFILE_S || arg == ARG_RSFILE_L) { _files.append(value); } else if (firstRun) { /* Place this arg/value in the map only first time*/ _args.insert(arg, value); } } }
/** Parses the list of command-line arguments for their argument names and * values. */ void Rshare::parseArguments(QStringList args) { QString arg, value; /* Loop through all command-line args/values and put them in a map */ for (int i = 0; i < args.size(); ++i) { /* Get the argument name and set a blank value */ arg = args.at(i).toLower(); value = ""; /* Check if it starts with a - or -- */ if (arg.startsWith("-")) { arg = arg.mid((arg.startsWith("--") ? 2 : 1)); } /* Check if it takes a value and there is one on the command-line */ if (i < args.size()-1 && argNeedsValue(arg)) { value = args.at(++i); } /* Place this arg/value in the map */ _args.insert(arg, value); } }