yes, of course.
The "pos" var is only to see something and always crash in the same position.
QRegExp rxArgPath
("^--sql_path=(.*)");
for (int i = 1; i < args.size(); ++i)
{
//qDebug() << args.at(i);
if(rxArgPath.indexIn(args.at(i), 0) == 0)
{
if(!rxArgPath.cap(1).isEmpty())
{
QFile sql_file
(rxArgPath.
cap(1));
if(sql_file.exists())
{
{
qDebug() << "reading file " << rxArgPath.cap(1);
int pos = 0;
do {
line = in.readLine();
qDebug() << "pos: " << pos << " length: " << line.length();
++pos;
} while (!line.isNull());
sql_file.close();
}
}
else
{
qWarning() << "Er: the file " << rxArgPath.cap(1) << "not exists";
}
}
else
{
qWarning() << "Er: Add the path --sql_path";
}
}
}
return a.exec();
QCoreApplication a(argc, argv);
QStringList args = QCoreApplication::arguments();
QRegExp rxArgPath("^--sql_path=(.*)");
for (int i = 1; i < args.size(); ++i)
{
//qDebug() << args.at(i);
if(rxArgPath.indexIn(args.at(i), 0) == 0)
{
if(!rxArgPath.cap(1).isEmpty())
{
QFile sql_file(rxArgPath.cap(1));
if(sql_file.exists())
{
if(sql_file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "reading file " << rxArgPath.cap(1);
QTextStream in(&sql_file);
QString line;
int pos = 0;
do {
line = in.readLine();
qDebug() << "pos: " << pos << " length: " << line.length();
++pos;
} while (!line.isNull());
sql_file.close();
}
}
else
{
qWarning() << "Er: the file " << rxArgPath.cap(1) << "not exists";
}
}
else
{
qWarning() << "Er: Add the path --sql_path";
}
}
}
return a.exec();
To copy to clipboard, switch view to plain text mode
thanks in advance
Bookmarks