VirtualBox

Changeset 83991 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Apr 27, 2020 10:08:37 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137558
Message:

IPRT,VBoxAddInstallNt3x.cpp: Split out the IPRT bits from VBoxAddInstallNt3x.cpp and move template to /Config.kmk.

Location:
trunk/src/VBox/Runtime/r3
Files:
3 added
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/RTPathTemp.cpp

    r83954 r83991  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Path Manipulation.
     3 * IPRT - Path Manipulation, RTPathTemp.
    44 */
    55
     
    3030*********************************************************************************************************************************/
    3131#include "internal/iprt.h"
     32#include <iprt/path.h>
     33
    3234#include <iprt/assert.h>
    3335#include <iprt/env.h>
    3436#include <iprt/err.h>
    35 #include <iprt/path.h>
    3637#include <iprt/string.h>
    3738#include "internal/path.h"
    38 #include "internal/process.h"
    39 
    40 
    41 #ifdef RT_OS_SOLARIS
    42 /**
    43  * Hack to strip of the architecture subdirectory from the exec dir.
    44  *
    45  * @returns See RTPathExecDir.
    46  * @param   pszPath             See RTPathExecDir.
    47  * @param   cchPath             See RTPathExecDir.
    48  */
    49 DECLINLINE(int) rtPathSolarisArchHack(char *pszPath, size_t cchPath)
    50 {
    51     int rc = RTPathExecDir(pszPath, cchPath);
    52     if (RT_SUCCESS(rc))
    53     {
    54         const char *pszLast = RTPathFilename(pszPath);
    55         if (   !strcmp(pszLast, "amd64")
    56             || !strcmp(pszLast, "i386"))
    57             RTPathStripFilename(pszPath);
    58     }
    59     return rc;
    60 }
    61 #endif
    62 
    63 
    64 RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath)
    65 {
    66     AssertReturn(g_szrtProcExePath[0], VERR_WRONG_ORDER);
    67 
    68     /*
    69      * Calc the length and check if there is space before copying.
    70      */
    71     size_t cch = g_cchrtProcDir;
    72     if (cch < cchPath)
    73     {
    74         memcpy(pszPath, g_szrtProcExePath, cch);
    75         pszPath[cch] = '\0';
    76         return VINF_SUCCESS;
    77     }
    78 
    79     AssertMsgFailed(("Buffer too small (%zu <= %zu)\n", cchPath, cch));
    80     return VERR_BUFFER_OVERFLOW;
    81 }
    82 
    83 
    84 RTDECL(int) RTPathAppPrivateNoArch(char *pszPath, size_t cchPath)
    85 {
    86 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE)
    87     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE);
    88 #elif defined(RT_OS_SOLARIS)
    89     return rtPathSolarisArchHack(pszPath, cchPath);
    90 #else
    91     return RTPathExecDir(pszPath, cchPath);
    92 #endif
    93 }
    94 
    95 
    96 RTDECL(int) RTPathAppPrivateArch(char *pszPath, size_t cchPath)
    97 {
    98 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH)
    99     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH);
    100 #else
    101     return RTPathExecDir(pszPath, cchPath);
    102 #endif
    103 }
    104 
    105 
    106 RTDECL(int) RTPathAppPrivateArchTop(char *pszPath, size_t cchPath)
    107 {
    108 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH_TOP)
    109     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH_TOP);
    110 #elif !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH)
    111     return RTStrCopy(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH);
    112 #elif defined(RT_OS_SOLARIS)
    113     return rtPathSolarisArchHack(pszPath, cchPath);
    114 #else
    115     int rc = RTPathExecDir(pszPath, cchPath);
    116     return rc;
    117 #endif
    118 }
    119 
    120 
    121 RTDECL(int) RTPathSharedLibs(char *pszPath, size_t cchPath)
    122 {
    123 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_SHARED_LIBS)
    124     return RTStrCopy(pszPath, cchPath, RTPATH_SHARED_LIBS);
    125 #else
    126     return RTPathExecDir(pszPath, cchPath);
    127 #endif
    128 }
    129 
    130 
    131 RTDECL(int) RTPathAppDocs(char *pszPath, size_t cchPath)
    132 {
    133 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_DOCS)
    134     return RTStrCopy(pszPath, cchPath, RTPATH_APP_DOCS);
    135 #elif defined(RT_OS_SOLARIS)
    136     return rtPathSolarisArchHack(pszPath, cchPath);
    137 #else
    138     return RTPathExecDir(pszPath, cchPath);
    139 #endif
    140 }
    14139
    14240
     
    17775}
    17876
    179 
    180 RTR3DECL(int) RTPathGetMode(const char *pszPath, PRTFMODE pfMode)
    181 {
    182     AssertPtrReturn(pfMode, VERR_INVALID_POINTER);
    183 
    184     RTFSOBJINFO ObjInfo;
    185     int rc = RTPathQueryInfoEx(pszPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);
    186     if (RT_SUCCESS(rc))
    187         *pfMode = ObjInfo.Attr.fMode;
    188 
    189     return rc;
    190 }
  • trunk/src/VBox/Runtime/r3/path.cpp

    r82968 r83991  
    3030*********************************************************************************************************************************/
    3131#include "internal/iprt.h"
     32#include <iprt/path.h>
     33
    3234#include <iprt/assert.h>
    33 #include <iprt/env.h>
    34 #include <iprt/err.h>
    35 #include <iprt/path.h>
     35#include <iprt/errcore.h>
    3636#include <iprt/string.h>
    3737#include "internal/path.h"
     
    141141
    142142
    143 RTDECL(int) RTPathTemp(char *pszPath, size_t cchPath)
    144 {
    145     /*
    146      * Try get it from the environment first.
    147      */
    148     static const char * const s_apszVars[] =
    149     {
    150         "IPRT_TMPDIR"
    151 #if defined(RT_OS_WINDOWS)
    152         , "TMP", "TEMP", "USERPROFILE"
    153 #elif defined(RT_OS_OS2)
    154         , "TMP", "TEMP", "TMPDIR"
    155 #else
    156         , "TMPDIR"
    157 #endif
    158     };
    159     for (size_t iVar = 0; iVar < RT_ELEMENTS(s_apszVars); iVar++)
    160     {
    161         int rc = RTEnvGetEx(RTENV_DEFAULT, s_apszVars[iVar], pszPath, cchPath, NULL);
    162         if (rc != VERR_ENV_VAR_NOT_FOUND)
    163             return rc;
    164     }
    165 
    166     /*
    167      * Here we should use some sane system default, instead we just use
    168      * the typical unix temp dir for now.
    169      */
    170     /** @todo Windows should default to the windows directory, see GetTempPath.
    171      * Some unixes has path.h and _PATH_TMP. There is also a question about
    172      * whether /var/tmp wouldn't be a better place...  */
    173     if (cchPath < sizeof("/tmp") )
    174         return VERR_BUFFER_OVERFLOW;
    175     memcpy(pszPath, "/tmp", sizeof("/tmp"));
    176     return VINF_SUCCESS;
    177 }
    178 
    179 
    180143RTR3DECL(int) RTPathGetMode(const char *pszPath, PRTFMODE pfMode)
    181144{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette