VirtualBox

Changeset 3861

Show
Ignore:
Timestamp:
07/26/07 11:15:14 (1 year ago)
Author:
vboxsync
Message:

use generic functions for determining paths instead of home-brewn solutions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r3859 r3861  
    6464#define BOOL PRBool 
    6565#endif 
     66 
     67#include <iprt/param.h> 
     68#include <iprt/path.h> 
    6669 
    6770#if defined (VBOX_GUI_DEBUG) 
     
    19982001    QString selectedLangId = gVBoxBuiltInLangName; 
    19992002 
    2000     QString nlsPath = qApp->applicationDirPath() + gVBoxLangSubDir; 
     2003    char szNlsPath[RTPATH_MAX]; 
     2004    int rc; 
     2005 
     2006    RTPathAppPrivateNoArch(szNlsPath, sizeof(szNlsPath)); 
     2007    Assert(RT_SUCCESS(rc)); 
     2008 
     2009    QString nlsPath = QString(szNlsPath) + gVBoxLangSubDir; 
    20012010    QDir nlsDir (nlsPath); 
    20022011 
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r3828 r3861  
    4040 
    4141#include <iprt/err.h> 
     42#include <iprt/param.h> 
     43#include <iprt/path.h> 
    4244 
    4345#if defined (Q_WS_WIN32) 
     
    17611763              HH_DISPLAY_TOPIC, NULL); 
    17621764#elif defined (Q_WS_X11) 
    1763     QString fullProgPath = qApp->applicationDirPath(); 
     1765    char szDocsPath[RTPATH_MAX]; 
     1766    int rc; 
     1767 
     1768    RTPathAppDocs(szDocsPath, sizeof(szDocsPath)); 
     1769    Assert(RT_SUCCESS(rc)); 
     1770 
     1771    QString fullProgPath = QString(szDocsPath); 
    17641772    QProcess kchmViewer (fullProgPath + "/kchmviewer"); 
    17651773    kchmViewer.addArgument (fullProgPath + "/VirtualBox.chm"); 
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r3833 r3861  
    46564656#ifdef VBOX_WITH_XPCOM 
    46574657    // VBoxC is located in the components subdirectory 
    4658     char szPathProgram[RTPATH_MAX + sizeof("/components/VBoxC")]; 
    4659     rc = RTPathProgram(szPathProgram, RTPATH_MAX);                                  AssertRC(rc); 
    4660     strcat(szPathProgram, "/components/VBoxC"); 
    4661     rc = CFGMR3InsertString(pMod,   "Path",  szPathProgram);                           RC_CHECK(); 
     4658    char szPathVBoxC[RTPATH_MAX]; 
     4659    rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc); 
     4660    strcat(szPathVBoxC, "/components/VBoxC"); 
     4661    rc = CFGMR3InsertString(pMod,   "Path",  szPathVBoxC);                             RC_CHECK(); 
    46624662#else 
    46634663    rc = CFGMR3InsertString(pMod,   "Path",  "VBoxC");                                 RC_CHECK(); 
  • trunk/src/VBox/Main/MachineImpl.cpp

    r3668 r3861  
    27882788    /* get the path to the executable */ 
    27892789    char path [RTPATH_MAX]; 
    2790     RTPathProgram (path, RTPATH_MAX); 
     2790    RTPathAppPrivateArch (path, RTPATH_MAX); 
    27912791    size_t sz = strlen (path); 
    27922792    path [sz++] = RTPATH_DELIMITER; 
  • trunk/src/VBox/Main/glue/initterm.cpp

    r3387 r3861  
    6464    DirectoryServiceProvider() 
    6565        : mCompRegLocation (NULL), mXPTIDatLocation (NULL) 
     66        , mComponentDirLocation (NULL), mCurrProcDirLocation (NULL) 
    6667        {} 
    6768 
     
    6970 
    7071    HRESULT init (const char *aCompRegLocation, 
    71                   const char *aXPTIDatLocation); 
     72                  const char *aXPTIDatLocation, 
     73                  const char *aComponentDirLocation, 
     74                  const char *aCurrProcDirLocation); 
    7275 
    7376    NS_DECL_NSIDIRECTORYSERVICEPROVIDER 
     
    7780    char *mCompRegLocation; 
    7881    char *mXPTIDatLocation; 
     82    char *mComponentDirLocation; 
     83    char *mCurrProcDirLocation; 
    7984}; 
    8085 
     
    9297        RTStrFree (mXPTIDatLocation); 
    9398        mXPTIDatLocation = NULL; 
     99    } 
     100    if (mComponentDirLocation) 
     101    { 
     102        RTStrFree (mComponentDirLocation); 
     103        mComponentDirLocation = NULL; 
     104    } 
     105    if (mCurrProcDirLocation) 
     106    { 
     107        RTStrFree (mCurrProcDirLocation); 
     108        mCurrProcDirLocation = NULL; 
    94109    } 
    95110} 
     
    101116HRESULT 
    102117DirectoryServiceProvider::init (const char *aCompRegLocation, 
    103                                 const char *aXPTIDatLocation) 
     118                                const char *aXPTIDatLocation, 
     119                                const char *aComponentDirLocation, 
     120                                const char *aCurrProcDirLocation) 
    104121{ 
    105122    AssertReturn (aCompRegLocation, NS_ERROR_INVALID_ARG); 
     
    109126    if (RT_SUCCESS (vrc)) 
    110127        vrc = RTStrUtf8ToCurrentCP (&mXPTIDatLocation, aXPTIDatLocation); 
     128    if (RT_SUCCESS (vrc) && aComponentDirLocation) 
     129        vrc = RTStrUtf8ToCurrentCP (&mComponentDirLocation, aComponentDirLocation); 
     130    if (RT_SUCCESS (vrc) && aCurrProcDirLocation) 
     131        vrc = RTStrUtf8ToCurrentCP (&mCurrProcDirLocation, aCurrProcDirLocation); 
    111132 
    112133    return RT_SUCCESS (vrc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; 
     
    130151    else if (strcmp (aProp, NS_XPCOM_XPTI_REGISTRY_FILE) == 0) 
    131152        fileLocation = mXPTIDatLocation; 
     153    else if (mComponentDirLocation && strcmp (aProp, NS_XPCOM_COMPONENT_DIR) == 0) 
     154        fileLocation = mComponentDirLocation; 
     155    else if (mCurrProcDirLocation && strcmp (aProp, NS_XPCOM_CURRENT_PROCESS_DIR) == 0) 
     156        fileLocation = mCurrProcDirLocation; 
    132157    else 
    133158        return NS_ERROR_FAILURE; 
     
    185210        /* prepare paths for registry files */ 
    186211        char homeDir [RTPATH_MAX]; 
     212        char privateArchDir [RTPATH_MAX]; 
    187213        int vrc = GetVBoxUserHomeDirectory (homeDir, sizeof (homeDir)); 
    188214        if (RT_SUCCESS (vrc)) 
     215            vrc = RTPathAppPrivateArch (privateArchDir, sizeof (privateArchDir)); 
     216        if (RT_SUCCESS (vrc)) 
    189217        { 
    190218            char compReg [RTPATH_MAX]; 
    191219            char xptiDat [RTPATH_MAX]; 
     220            char compDir [RTPATH_MAX]; 
    192221 
    193222            RTStrPrintf (compReg, sizeof (compReg), "%s%c%s", 
     
    195224            RTStrPrintf (xptiDat, sizeof (xptiDat), "%s%c%s", 
    196225                         homeDir, RTPATH_DELIMITER, "xpti.dat"); 
     226            RTStrPrintf (compDir, sizeof (compDir), "%s%c/components", 
     227                         privateArchDir, RTPATH_DELIMITER); 
    197228 
    198229            dsProv = new DirectoryServiceProvider(); 
    199230            if (dsProv) 
    200                 rc = dsProv->init (compReg, xptiDat); 
     231                rc = dsProv->init (compReg, xptiDat, compDir, privateArchDir); 
    201232            else 
    202233                rc = NS_ERROR_OUT_OF_MEMORY; 
  • trunk/src/VBox/VMM/PDMLdr.cpp

    r2981 r3861  
    940940static char * pdmR3File(const char *pszFile, const char *pszDefaultExt, bool fShared) 
    941941{ 
    942     char    *pszRet; 
    943  
    944 #ifdef VBOX_PATH_PRIVATE_LIBS 
    945  
    946     /* 
    947      * Unix: Search in /usr/lib/virtualbox 
    948      */ 
    949     pszRet = pdmR3FileConstruct( 
    950 # ifdef VBOX_PATH_SHARED_LIBS 
    951                                 fShared ? VBOX_PATH_SHARED_LIBS : VBOX_PATH_PRIVATE_LIBS, 
    952 # else 
    953                                 VBOX_PATH_PRIVATE_LIBS, 
    954 # endif 
    955                                 pszFile, pszDefaultExt); 
    956  
    957 #else 
    958  
    959     NOREF(fShared); 
    960  
    961     /* 
    962      * Default: Search in the program path. 
    963      */ 
    964     char     szPath[RTPATH_MAX]; 
    965     int rc = RTPathProgram(szPath, sizeof(szPath)); 
     942    char szPath[RTPATH_MAX]; 
     943    int  rc; 
     944     
     945    rc = fShared ? RTPathSharedLibs(szPath, sizeof(szPath))  
     946                 : RTPathAppPrivateArch(szPath, sizeof(szPath)); 
    966947    if (!VBOX_SUCCESS(rc)) 
    967948    { 
     
    970951    } 
    971952 
    972     pszRet = pdmR3FileConstruct(szPath, pszFile, pszDefaultExt); 
    973  
    974 #endif 
    975  
    976     return pszRet; 
     953    return pdmR3FileConstruct(szPath, pszFile, pszDefaultExt); 
    977954} 
    978955 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy