コード例 #1
0
void KURLCompletion::adjustMatch(QString &match) const
{
    if(match.at(match.length() - 1) != '/')
    {
        QString copy;

        if(match.startsWith(QString("file:")))
            copy = KURL(match).path();
        else
            copy = match;

        expandTilde(copy);
        expandEnv(copy);
        if(QDir::isRelativePath(copy))
            copy.prepend(d->cwd + '/');

        //		kdDebug() << "postProcess: stating " << copy << endl;

        KDE_struct_stat sbuff;

        QCString file = QFile::encodeName(copy);

        if(KDE_stat((const char *)file, &sbuff) == 0)
        {
            if(S_ISDIR(sbuff.st_mode))
                match.append('/');
        }
        else
        {
            kdDebug() << "Could not stat file " << copy << endl;
        }
    }
}
コード例 #2
0
void KURLCompletion::MyURL::filter(bool replace_user_dir, bool replace_env)
{
    QString d = dir() + file();
    if(replace_user_dir)
        expandTilde(d);
    if(replace_env)
        expandEnv(d);
    m_kurl->setPath(d);
}
コード例 #3
0
ファイル: csc_file.c プロジェクト: hajuuk/R7000
PUBLIC char*   (CSCfileExpandPath) (
                                   const char*            const path,
                                   const size_t                 pathMax,
                                         CSCmemListType   const memList,
                                         int                    memTag
                                   )
   {
   char*    dstPtr = NULL;
   char*    tmpPtr = NULL;
   char*    srcPtr = (char*)path;
   size_t   index;

   ASSERT_RTN (path != NULL,    "CSCfileExpandPath: NULL path",    NULL);
   ASSERT_RTN (pathMax > 0,     "CSCfileExpandPath: no pathMax",   NULL);
   ASSERT_RTN (memList != NULL, "CSCfileExpandPath: NULL memList", NULL);

   ASSERT (sizeof(ptrdiff_t) <= sizeof(size_t)); /* note #1 */

   if ((path == NULL) || (pathMax == 0) || (memList == NULL)) return (NULL);

   if (CSCmemAlloc(memList,(void**)&dstPtr,1,pathMax+1,memTag) == CSC_OK)
      {
      (void)memset (dstPtr, '\0', pathMax+1);

      tmpPtr = expandTilde (dstPtr, &srcPtr, pathMax);
      if (tmpPtr != NULL)
         index = (size_t)(tmpPtr - dstPtr); /* note #1 */
      else
         {
         index = (size_t)pathMax + 1;
         }

      while ((*srcPtr != '\0') && (index <= pathMax))
         {
         while ((*srcPtr != '$') && (*srcPtr != '\0') && (index++ <= pathMax))
            {
            *tmpPtr++ = *srcPtr++;
            }
         if (*srcPtr == '$')
            {
            tmpPtr = expandEnv (tmpPtr, &srcPtr, pathMax-index);
            index = (size_t)(tmpPtr - dstPtr); /* note #1 */
            }
         }
      *tmpPtr = '\0';

      if (*srcPtr != '\0')
         {
         (void)CSCmemFree (memList, (void**)&dstPtr, memTag);
         dstPtr = NULL;
         }
      }

   return (dstPtr);
   }
コード例 #4
0
ファイル: Node.cpp プロジェクト: mwtoews/libgeos
/* static public */
std::unique_ptr<Node>
Node::createExpanded(std::unique_ptr<Node> node, const Envelope& addEnv)
{
	Envelope expandEnv(addEnv);
	if ( node.get() ) // should this be asserted ?
	{
		expandEnv.expandToInclude(node->getEnvelope());
	}

#if GEOS_DEBUG
	cerr<<"Node::createExpanded computed "<<expandEnv.toString()<<endl;
#endif

	std::unique_ptr<Node> largerNode = createNode(expandEnv);
	if ( node.get() ) // should this be asserted ?
	{
		largerNode->insertNode(std::move(node));
	}

	return largerNode;
}
コード例 #5
0
int RewriteEngine::processRewrite( const RewriteRule * pRule, HttpConnection *pConn )
{
    char * pBuf;
    int flag = pRule->getFlag();
    expandEnv( pRule, pConn );
    m_rewritten |= 1;
    if (!( flag & RULE_FLAG_NOREWRITE ))
    {
        int len = REWRITE_BUF_SIZE - 1;
        pBuf = m_pDestURL;
        m_pDestURL = m_pFreeBuf;
        m_pFreeBuf = pBuf;
        m_flag = flag;
        pBuf = buildString( pRule->getTargetFmt(), pConn, m_pDestURL, len, 1, 1 );
        // log rewrite result here
        if ( !pBuf )
        {
            if ( m_logLevel > 0 )
                LOG_ERR(( pConn->getLogger(),
                    "[%s] [REWRITE] Failed to build the target URI",
                        pConn->getLogId() ));
            return -1;
        }

//         if ( strchr( pBuf, '%' ) )
//         {
//             int c;
//             int l, l1;
//             char * pEnd = strchr( pBuf, '?' );
//             if ( pEnd )
//                 l = pEnd - pBuf;
//             else
//                 l = len;
//             l1 = transform_urlDecode( pBuf, l, pBuf, l, &c );
//             len -= l - l1;
//         }

        if ( m_logLevel > 0 )
            LOG_INFO(( pConn->getLogger(),
                    "[%s] [REWRITE] Source URI: '%s' => Result URI: '%s'",
                    pConn->getLogId(), m_pSourceURL, pBuf ));
        m_rewritten |= 2;
        m_pOrgSourceURL = m_pSourceURL;
        m_orgSourceURLLen = m_sourceURLLen;
        m_pSourceURL = pBuf;
        m_sourceURLLen = len;
        m_iScriptLen = -1;
        m_iPathInfoLen = 0;
        if ( flag & (RULE_FLAG_WITHQS|RULE_FLAG_QSDISCARD) )
        {
            processQueryString( pConn, flag );
        }
    }
    else if ( m_logLevel > 0 )
        LOG_INFO(( pConn->getLogger(),
                "[%s] [REWRITE] No substition",
                pConn->getLogId()));
    
    if ( pRule->getAction() != RULE_ACTION_NONE )
    {
        m_action = pRule->getAction();
        m_statusCode = pRule->getStatusCode();
        return 0;
    }

    if ( pRule->getMimeType() )
    {
        if ( m_logLevel > 4 )
            LOG_INFO(( pConn->getLogger(),
                "[%s] [REWRITE] set forced type: '%s'",
                pConn->getLogId(), pRule->getMimeType() ));
        pConn->getReq()->setForcedType( pRule->getMimeType() );
    }
    return 0;
}
コード例 #6
0
ファイル: turtle.c プロジェクト: kevinqmcdonald/shellproject
char * cleanInput( char * in ) {
	return expandTilde( expandEnv( removeQuotes( in ) ) );
}
コード例 #7
0
QString ShellCommand::expand(const QString & text)
{
    QString result = text;
    expandEnv(result);
    return result;
}