[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Handling filenames with spaces.
From:       markcox <markcox () iprimus ! com ! au>
Date:       2002-05-02 13:06:26
[Download RAW message or body]

Thanks for the help David, that is what i was looking for. 
I came across an inconsistency though:

Compare this function from kprocess.cpp

QString KProcess::quote(const QString &arg)
{
    QString res = arg;
    res.replace(QRegExp(QString::fromLatin1("\'")),
                QString::fromLatin1("'\"'\"'"));
    res.prepend('\'');
    res.append('\'');
    return res;
}

To this one from krun.cpp

void KRun::shellQuote( QString &_str )
{
    // Credits to Walter, says Bernd G. :)
    if (_str.isEmpty()) // Don't create an explicit empty parameter
        return;
    QString res = "'";
    res += _str.replace(QRegExp("'"), "'\"'\"'");
    res += "'";
    _str = res;
}

Is one implementation more correct than the other? 
Is it possible for one to be implemented in terms of the other to reduce 
duplication? They are both from kdelibs, so can we just have

QString KProcess::quote(const QString &arg)
{
    QString res = arg;
    KRun::shellQuote(res);
    return res;
}

And include krun.h ?????

Mark Cox

On Tue, 30 Apr 2002 21:48, David Faure wrote:
> On Tuesday 30 April 2002 13:20, markcox wrote:
> > In the following code in cdbakeoven,
> > The command calling mpg123 does not correctly handle spaces in the
> > filename.
> >
> > <snippet>
> >
> > if(mType.find("x-mp3") != -1)
> > {
> > 		*cdboShellProc << "mpg123 -v -s " + file + " > " + outName;
> > 		tmpList->append(outName);
> >
> > </snippet>
>
> [...]
>
> > What is the 'kde way' to do this?
>
> KRun::shellQuote( file );

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic