Ejemplo n.º 1
0
static int
get_date( const char *str )
{
	KProcIO prc;
	prc << "/bin/date" << "+%s" << "-d" << str;
	prc.start( TDEProcess::Block, false );
	TQString dstr;
	if (prc.readln( dstr, false, 0 ) < 0)
		return -1;
	return dstr.toInt();
}
Ejemplo n.º 2
0
void KFileShare::readShareList()
{
    KFileSharePrivate::self();
    if(!s_shareList)
        sdShareList.setObject(s_shareList, new QStringList);
    else
        s_shareList->clear();

    // /usr/sbin on Mandrake, $PATH allows flexibility for other distributions
    QString exe = findExe("filesharelist");
    if(exe.isEmpty())
    {
        s_authorization = ErrorNotFound;
        return;
    }
    KProcIO proc;
    proc << exe;
    if(!proc.start(KProcess::Block))
    {
        kdError() << "Can't run " << exe << endl;
        s_authorization = ErrorNotFound;
        return;
    }

    // Reading code shamelessly stolen from khostname.cpp ;)
    QString line;
    int length;
    do
    {
        length = proc.readln(line, true);
        if(length > 0)
        {
            if(line[length - 1] != '/')
                line += '/';
            s_shareList->append(line);
            kdDebug(7000) << "Shared dir:" << line << endl;
        }
    } while(length > -1);
}