VirtualBox

Changeset 3860 in vbox


Ignore:
Timestamp:
Jul 26, 2007 9:13:25 AM (18 years ago)
Author:
vboxsync
Message:

introduced some generic IPRT functions for requesting several pathes

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/path.h

    r3636 r3860  
    313313
    314314/**
    315  * Gets the directory for architecture-independent shared data.
    316  * Unix:    /usr/share/<application>
    317  * Windows: <program files directory>/<application>
     315 * Gets the directory of shared libraries. This is not the same as
     316 * RTPathAppPrivateArch() as Linux depends all shared libraries in
     317 * a common global directory where ld.so can found them.
     318 *
     319 * Linux:    /usr/lib
     320 * Windows:  <program files directory>/<application>
     321 * Old path: same as RTPathProgram()
    318322 *
    319323 * @returns iprt status code.
     
    321325 * @param   cchPath     Buffer size in bytes.
    322326 */
    323 RTDECL(int) RTPathAppShared(char *pszPath, unsigned cchPath);
    324 
    325 /**
    326  * Gets the directory for architecture-dependent shared data.
    327  * Unix:    /usr/lib/<application>.
    328  * Windows: same as RTPathAppShared()
     327RTDECL(int) RTPathSharedLibs(char *pszPath, unsigned cchPath);
     328
     329/**
     330 * Gets the directory for architecture-independent application data, for
     331 * example NLS files, module sources, ...
     332 *
     333 * Linux:    /usr/shared/<application>
     334 * Windows:  <program files directory>/<application>
     335 * Old path: same as RTPathProgram()
    329336 *
    330337 * @returns iprt status code.
     
    332339 * @param   cchPath     Buffer size in bytes.
    333340 */
    334 RTDECL(int) RTPathAppSharedArch(char *pszPath, unsigned cchPath);
    335 
    336 /**
    337  * Gets the directory for documentation.
    338  * Unix:    /usr/share/doc/<application>.
    339  * Windows: same as RTPathAppShared()
     341RTDECL(int) RTPathAppPrivateNoArch(char *pszPath, unsigned cchPath);
     342
     343/**
     344 * Gets the directory for architecture-dependent application data, for
     345 * example modules which can be loaded at runtime.
     346 *
     347 * Linux:    /usr/lib/<application>
     348 * Windows:  <program files directory>/<application>
     349 * Old path: same as RTPathProgram()
    340350 *
    341351 * @returns iprt status code.
     
    343353 * @param   cchPath     Buffer size in bytes.
    344354 */
    345 RTDECL(int) RTPathAppDoc(char *pszPath, unsigned cchPath);
     355RTDECL(int) RTPathAppPrivateArch(char *pszPath, unsigned cchPath);
     356
     357/**
     358 * Gets the directory for documentation.
     359 *
     360 * Linux:    /usr/share/doc/<application>
     361 * Windows:  <program files directory>/<application>
     362 * Old path: same as RTPathProgram()
     363 *
     364 * @returns iprt status code.
     365 * @param   pszPath     Buffer where to store the path.
     366 * @param   cchPath     Buffer size in bytes.
     367 */
     368RTDECL(int) RTPathAppDocs(char *pszPath, unsigned cchPath);
    346369
    347370/**
  • trunk/src/VBox/Runtime/path.cpp

    r3672 r3860  
    3434#include <iprt/uni.h>
    3535#include "internal/fs.h"
     36#include "internal/path.h"
    3637
    3738
     
    547548}
    548549
     550
     551/**
     552 * Gets the directory for architecture-independent application data, for
     553 * example NLS files, module sources, ...
     554 *
     555 * Linux:    /usr/shared/<application>
     556 * Windows:  <program files directory>/<application>
     557 * Old path: same as RTPathProgram()
     558 *
     559 */
     560RTDECL(int) RTPathAppPrivateNoArch(char *pszPath, unsigned cchPath)
     561{
     562#ifdef RTPATH_APP_PRIVATE
     563    char *pszUtf8Path;
     564    int rc;
     565    rc = rtPathFromNative(&pszUtf8Path, RTPATH_APP_PRIVATE);
     566    if (RT_SUCCESS(rc))
     567    {
     568        size_t cchPathPrivateNoArch = strlen(pszUtf8Path);
     569        if (cchPathPrivateNoArch < cchPath)
     570            memcpy(pszPath, pszUtf8Path, cchPathPrivateNoArch + 1);
     571        else
     572            rc = VERR_BUFFER_OVERFLOW;
     573        RTStrFree(pszUtf8Path);
     574    }
     575    return rc;
     576#else
     577    return RTPathProgram(pszPath, cchPath);
     578#endif
     579}
     580
     581
     582/**
     583 * Gets the directory for architecture-dependent application data, for
     584 * example modules which can be loaded at runtime.
     585 *
     586 * Linux:    /usr/lib/<application>
     587 * Windows:  <program files directory>/<application>
     588 * Old path: same as RTPathProgram()
     589 *
     590 * @returns iprt status code.
     591 * @param   pszPath     Buffer where to store the path.
     592 * @param   cchPath     Buffer size in bytes.
     593 */
     594RTDECL(int) RTPathAppPrivateArch(char *pszPath, unsigned cchPath)
     595{
     596#ifdef RTPATH_APP_PRIVATE_ARCH
     597    char *pszUtf8Path;
     598    int rc;
     599    rc = rtPathFromNative(&pszUtf8Path, RTPATH_APP_PRIVATE_ARCH);
     600    if (RT_SUCCESS(rc))
     601    {
     602        size_t cchPathPrivateArch = strlen(pszUtf8Path);
     603        if (cchPathPrivateArch < cchPath)
     604            memcpy(pszPath, pszUtf8Path, cchPathPrivateArch + 1);
     605        else
     606            rc = VERR_BUFFER_OVERFLOW;
     607        RTStrFree(pszUtf8Path);
     608    }
     609    return rc;
     610#else
     611    return RTPathProgram(pszPath, cchPath);
     612#endif
     613}
     614
     615
     616/**
     617 * Gets the directory of shared libraries. This is not the same as
     618 * RTPathAppPrivateArch() as Linux depends all shared libraries in
     619 * a common global directory where ld.so can found them.
     620 *
     621 * Linux:    /usr/lib
     622 * Windows:  <program files directory>/<application>
     623 * Old path: same as RTPathProgram()
     624 *
     625 * @returns iprt status code.
     626 * @param   pszPath     Buffer where to store the path.
     627 * @param   cchPath     Buffer size in bytes.
     628 */
     629RTDECL(int) RTPathSharedLibs(char *pszPath, unsigned cchPath)
     630{
     631#ifdef RTPATH_SHARED_LIBS
     632    char *pszUtf8Path;
     633    int rc;
     634    rc = rtPathFromNative(&pszUtf8Path, RTPATH_SHARED_LIBS);
     635    if (RT_SUCCESS(rc))
     636    {
     637        size_t cchPathSharedLibs = strlen(pszUtf8Path);
     638        if (cchPathSharedLibs < cchPath)
     639            memcpy(pszPath, pszUtf8Path, cchPathSharedLibs + 1);
     640        else
     641            rc = VERR_BUFFER_OVERFLOW;
     642        RTStrFree(pszUtf8Path);
     643    }
     644    return rc;
     645#else
     646    return RTPathProgram(pszPath, cchPath);
     647#endif
     648}
     649
     650
     651/**
     652 * Gets the directory for documentation.
     653 *
     654 * Linux:    /usr/share/doc/<application>
     655 * Windows:  <program files directory>/<application>
     656 * Old path: same as RTPathProgram()
     657 *
     658 * @returns iprt status code.
     659 * @param   pszPath     Buffer where to store the path.
     660 * @param   cchPath     Buffer size in bytes.
     661 */
     662RTDECL(int) RTPathAppDocs(char *pszPath, unsigned cchPath)
     663{
     664#ifdef RTPATH_APP_DOCS
     665    char *pszUtf8Path;
     666    int rc;
     667    rc = rtPathFromNative(&pszUtf8Path, RTPATH_APP_DOCS);
     668    if (RT_SUCCESS(rc))
     669    {
     670        size_t cchPathAppDocs = strlen(pszUtf8Path);
     671        if (cchPathAppDocs < cchPath)
     672            memcpy(pszPath, pszUtf8Path, cchPathAppDocs + 1);
     673        else
     674            rc = VERR_BUFFER_OVERFLOW;
     675        RTStrFree(pszUtf8Path);
     676    }
     677    return rc;
     678#else
     679    return RTPathProgram(pszPath, cchPath);
     680#endif
     681}
Note: See TracChangeset for help on using the changeset viewer.

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