This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 388 for ps


Ignore:
Timestamp:
06/03/04 19:34:49 (21 years ago)
Author:
Simon Brenner
Message:

\ handling for vfs entity resolver.. ugly as hell, but works :P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/ps/XMLUtils.cpp

    r380 r388  
    11#include "XML.h"
    22#include "CStr.h"
     3#include "CLogger.h"
    34
    45#include "res/vfs.h"
     
    2526
    2627    m_hFile=vfs_open(path);
    27     if (m_hFile <= 0) return -1;
     28    if (m_hFile <= 0)
     29    {
     30        LOG(ERROR, "CVFSInputSource: file %s couldn't be opened (vfs_open)\n", path);
     31        return -1;
     32    }
    2833   
    29     if (vfs_map(m_hFile, 0, m_pBuffer, m_BufferSize) != 0)
     34    int err;
     35    if ((err=vfs_map(m_hFile, 0, m_pBuffer, m_BufferSize)) != 0)
    3036    {
     37        LOG(ERROR, "CVFSInputSource: file %s couldn't be opened (vfs_map: %d)\n", path, err);
    3138        vfs_close(m_hFile);
    3239        m_hFile=0;
     
    6875    char *orgpath=path;
    6976   
    70     CStr base=m_DocName;
    71     const char *end=m_DocName+base.Length();
    72     if (strncmp(path, "../", 3) == 0)
     77    CStr abspath=m_DocName;
     78    const char *end=m_DocName+abspath.Length();
     79    if (strncmp(path, "..", 2) == 0 && (path[2] == '/' || path[2] == '\\'))
    7380    {
    7481        do
    7582            --end;
    76         while (end > m_DocName && *end != '/');
     83        while (end > m_DocName && (*end != '/' && *end != '\\'));
    7784
    78         while (strncmp(path, "../", 3) == 0)
     85        while (strncmp(path, "..", 2) == 0 && (path[2] == '/' || path[2] == '\\'))
    7986        {
    8087            path += 3;
     
    8289            do
    8390                --end;
    84             while (end > m_DocName && *end != '/');
     91            while (end > m_DocName && (*end != '/' && *end != '\\'));
    8592        }
    8693       
    8794        --path;
     95       
     96        abspath=abspath.Left(end-m_DocName)+path;
     97       
     98        int pos=0;
     99        if (abspath.Find('\\') != -1)
     100        {
     101            LOG(WARNING, "While resolving XML entities for %s: path %s [%s] contains non-portable path separator \\", m_DocName, orgpath, abspath.c_str());
     102            abspath.Replace("\\", "/");
     103        }
    88104    }
    89105   
    90     if (
    91         (orgpath != path &&
    92             ret->OpenFile((base.Left(end-m_DocName)+path).c_str())!=0)
     106    if ((orgpath != path && ret->OpenFile(abspath)!=0)
    93107        || (orgpath == path && ret->OpenFile(path)!=0))
    94108    {
Note: See TracChangeset for help on using the changeset viewer.