本文整理汇总了C++中KUrl::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::filename方法的具体用法?C++ KUrl::filename怎么用?C++ KUrl::filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::filename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
QString
PixmapCollection::addPixmapPath(const KUrl &url)
{
QString name = url.filename();
while (m_pixmaps.contains(name)) {
bool ok;
int num = name.right(1).toInt(&ok, 10);
if (ok)
name = name.left(name.length() - 1) + QString::number(num + 1);
else
name += "2";
}
m_pixmaps.insert(name, qMakePair(url.path(), 0));
return name;
}
示例2: get
void CgiProtocol::get( const KUrl& url )
{
kDebug(7124) << "CgiProtocol::get()";
kDebug(7124) << " URL: " << url.url();
#if 0
kDebug(7124) << " Path: " << url.path();
kDebug(7124) << " Query: " << url.query();
kDebug(7124) << " Protocol: " << url.protocol();
kDebug(7124) << " Filename: " << url.filename();
#endif
QByteArray protocol = "SERVER_PROTOCOL=HTTP";
putenv( protocol.data() );
QByteArray requestMethod = "REQUEST_METHOD=GET";
putenv( requestMethod.data() );
QByteArray query = url.query().mid( 1 ).toLocal8Bit();
query.prepend( "QUERY_STRING=" );
putenv( query.data() );
QString path = url.path();
QString file;
int pos = path.lastIndexOf('/');
if ( pos >= 0 ) file = path.mid( pos + 1 );
else file = path;
QString cmd;
bool stripHeader = false;
bool forwardFile = true;
QStringList::ConstIterator it;
for( it = mCgiPaths.constBegin(); it != mCgiPaths.constEnd(); ++it ) {
cmd = *it;
if ( !(*it).endsWith('/') )
cmd += '/';
cmd += file;
if ( KStandardDirs::exists( cmd ) ) {
forwardFile = false;
stripHeader = true;
break;
}
}
FILE *fd;
if ( forwardFile ) {
kDebug(7124) << "Forwarding to '" << path << "'";
QByteArray filepath = QFile::encodeName( path );
fd = fopen( filepath.data(), "r" );
if ( !fd ) {
kDebug(7124) << "Error opening '" << filepath << "'";
error(KIO::ERR_CANNOT_OPEN_FOR_READING, path);
return;
}
} else {
kDebug(7124) << "Cmd: " << cmd;
fd = popen( QFile::encodeName(KShell::quoteArg( cmd )).data(), "r" );
if ( !fd ) {
kDebug(7124) << "Error running '" << cmd << "'";
error( KIO::ERR_CANNOT_OPEN_FOR_READING, cmd );
return;
}
}
char buffer[ 4090 ];
while ( !feof( fd ) )
{
int n = fread( buffer, 1, 2048, fd );
if ( n == -1 )
{
// ERROR
if ( forwardFile ) {
fclose( fd );
} else {
pclose( fd );
}
return;
}
buffer[n] = 0;
if ( stripHeader ) {
QByteArray output = buffer; // this assumes buffer is text and not binary
int colon = output.indexOf( ':' );
int newline = output.indexOf( '\n' );
int semicolon = output.lastIndexOf( ';', newline );
int end;
if ( semicolon < 0 ) end = newline;
else end = semicolon;
//.........这里部分代码省略.........